(This is a cut-down version of the Class of the same name in ph-commons-util.)
| Modifier and Type | Field and Description |
|---|---|
| public static final int | BUFFER_SIZE
Buffer size when transferring streams |
| public static final int | MAX_TEXT_STREAM_SIZE
Maximum size of characters we'll read from a text stream before complaining |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static void | ensureClose(Closeable...
"streams" to close streams)Ensures that as many of the given |
| public static File | |
| public static File | |
| public static String | Returns: String representing the data readsource of string data reader)Reads all character data from the given Reader, returning a String containing all of the data. |
| public static String | Returns: String representing the data we read inFile to read from file)Same as |
| public static String | Returns: String representing the data read inInputStream supplying character data in)Same as |
| public static void | transfer(InputStream inStream, OutputStream outStream)
"Transfers" data from the given InputStream to the given OutputStream, closing both streams once the InputStream has been exhausted. |
| public static void | transfer(FileInputStream fileInStream, FileOutputStream fileOutStream)
Version of |
| public static void | transfer(InputStream inStream, OutputStream outStream, boolean closeOutputStream)
"Transfers" data from the given InputStream to the given OutputStream, closing the InputStream afterwards. |
| public static void | transfer(InputStream inStream, OutputStream outStream, boolean closeInputStream, boolean closeOutputStream)
"Transfers" data from the given InputStream to the given OutputStream, optionally closing the given input and output streams afterwards. |
| BUFFER_SIZE | back to summary |
|---|---|
| public static final int BUFFER_SIZE Buffer size when transferring streams | |
| MAX_TEXT_STREAM_SIZE | back to summary |
|---|---|
| public static final int MAX_TEXT_STREAM_SIZE Maximum size of characters we'll read from a text stream before complaining | |
| IOUtilities | back to summary |
|---|---|
| public IOUtilities() | |
| ensureClose | back to summary |
|---|---|
| public static void ensureClose(Closeable... streams) throws IOException Ensures that as many of the given For convenience, any number of the stream may be null, in which case they will be ignored.
| |
| ensureDirectoryCreated | back to summary |
|---|---|
| public static File ensureDirectoryCreated(File directory) throws IOException Simple method to ensure that a given directory exists. If the directory does not exist then it is created, along with all required parents.
| |
| ensureFileCreated | back to summary |
|---|---|
| public static File ensureFileCreated(File file) throws IOException Simple method to ensure that a given File exists. If the File does not exist then it is created, along with all required parent directories.
| |
| readCharacterStream | back to summary |
|---|---|
| public static String readCharacterStream(Reader reader) throws IOException Reads all character data from the given Reader, returning a String containing all of the data. The Reader will be buffered for efficiency and will be closed once finished with. Be careful reading in very large files - we will barf if MAX_FILE_SIZE is passed as a safety precaution. | |
| readUnicodeFile | back to summary |
|---|---|
| public static String readUnicodeFile(File file) throws IOException Same as | |
| readUnicodeStream | back to summary |
|---|---|
| public static String readUnicodeStream(InputStream in) throws IOException Same as
| |
| transfer | back to summary |
|---|---|
| public static void transfer(InputStream inStream, OutputStream outStream) throws IOException "Transfers" data from the given InputStream to the given OutputStream, closing both streams once the InputStream has been exhausted.
This will check to see if both streams are File streams and, if so, use the
| |
| transfer | back to summary |
|---|---|
| public static void transfer(FileInputStream fileInStream, FileOutputStream fileOutStream) throws IOException Version of | |
| transfer | back to summary |
|---|---|
| public static void transfer(InputStream inStream, OutputStream outStream, boolean closeOutputStream) throws IOException "Transfers" data from the given InputStream to the given OutputStream, closing the InputStream afterwards. If the parameter closeOutputStream is true then the OutputStream is closed too. If not, it will be flushed. | |
| transfer | back to summary |
|---|---|
| public static void transfer(InputStream inStream, OutputStream outStream, boolean closeInputStream, boolean closeOutputStream) throws IOException "Transfers" data from the given InputStream to the given OutputStream, optionally closing the given input and output streams afterwards. Even if not closing the output stream, it will still be flushed. | |