public class IOHelper extends Object
| Constructor and Description |
|---|
IOHelper() |
| Modifier and Type | Method and Description |
|---|---|
static void |
close(InputStream stream) |
static void |
copyStream(InputStream in,
OutputStream out)
Copy remaining stream content to another stream.
|
static void |
copyStream(InputStream in,
OutputStream out,
int copyBufferSize)
Copy remaining stream content to another stream.
|
static byte[] |
readFile(String filePath)
Read a file on the file system and return its content as a stream of bytes.
|
public static void close(InputStream stream)
public static byte[] readFile(String filePath) throws IOException
filePath - Path of the file to read. Cannot be null.IOException - on errorpublic static void copyStream(InputStream in, OutputStream out) throws IOException
in - Input stream to copy (remaining) content from. Cannot be null.out - Output stream to copy content to. Cannot be null.IOException - on IO error.AssertionError - If in or out is null.public static void copyStream(InputStream in, OutputStream out, int copyBufferSize) throws IOException
in - Input stream to copy (remaining) content from. Cannot be null.out - Output stream to copy content to. Cannot be null.copyBufferSize - Size of the maximum chunk of data that will be copied in one step. A
buffer a this size will be allocated internally so beware of the usual speed vs. memory
tradeoff. Must be strictly positive.IOException - on IO error.AssertionError - If copyBufferSize is negative, in is
null or out is null.Copyright © 2013. All rights reserved.