public class IOUtils extends Object
| Modifier and Type | Field | Description |
|---|---|---|
static int |
EOF |
Represents the end-of-file (or stream).
|
| Constructor | Description |
|---|---|
IOUtils() |
| Modifier and Type | Method | Description |
|---|---|---|
static int |
copy(Reader input,
Writer output) |
Copies chars from a
Reader to a Writer. |
static long |
copyLarge(Reader input,
Writer output) |
Copies chars from a large (over 2GB)
Reader to a Writer. |
static long |
copyLarge(Reader input,
Writer output,
char[] buffer) |
Copies chars from a large (over 2GB)
Reader to a Writer. |
static String |
toString(Reader input) |
Gets the contents of a
Reader as a String. |
public static final int EOF
public static int copy(Reader input, Writer output) throws IOException
Reader to a Writer.
This method buffers the input internally, so there is no need to use a
BufferedReader.
Large streams (over 2GB) will return a chars copied value of
-1 after the copy has completed since the correct
number of chars cannot be returned as an int. For large streams
use the copyLarge(Reader, Writer) method.input - the Reader to read fromoutput - the Writer to write toNullPointerException - if the input or output is nullIOException - if an I/O error occurspublic static long copyLarge(Reader input, Writer output) throws IOException
Reader to a Writer.
This method buffers the input internally, so there is no need to use a
BufferedReader.
The buffer size is given by DEFAULT_BUFFER_SIZE.input - the Reader to read fromoutput - the Writer to write toNullPointerException - if the input or output is nullIOException - if an I/O error occurspublic static long copyLarge(Reader input, Writer output, char[] buffer) throws IOException
Reader to a Writer.
This method uses the provided buffer, so there is no need to use a
BufferedReader.
input - the Reader to read fromoutput - the Writer to write tobuffer - the buffer to be used for the copyNullPointerException - if the input or output is nullIOException - if an I/O error occurspublic static String toString(Reader input) throws IOException
Reader as a String.
This method buffers the input internally, so there is no need to use a
BufferedReader.input - the Reader to read fromNullPointerException - if the input is nullIOException - if an I/O error occursCopyright © 1999-2018. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.