public class IOUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private static int |
DEFAULT_BUFFER_SIZE
The default buffer size (4096) to use for
#copyLarge(InputStream, OutputStream)
and
copyLarge(Reader, Writer) |
static int |
EOF
Represents the end-of-file (or stream).
|
| Constructor and Description |
|---|
IOUtils() |
| Modifier and Type | Method and Description |
|---|---|
static int |
copy(java.io.Reader input,
java.io.Writer output)
Copies chars from a
Reader to a Writer. |
static long |
copyLarge(java.io.Reader input,
java.io.Writer output)
Copies chars from a large (over 2GB)
Reader to a Writer. |
static long |
copyLarge(java.io.Reader input,
java.io.Writer output,
char[] buffer)
Copies chars from a large (over 2GB)
Reader to a Writer. |
static java.lang.String |
toString(java.io.Reader input)
Gets the contents of a
Reader as a String. |
private static final int DEFAULT_BUFFER_SIZE
#copyLarge(InputStream, OutputStream)
and
copyLarge(Reader, Writer)public static final int EOF
public static int copy(java.io.Reader input,
java.io.Writer output)
throws java.io.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 tojava.lang.NullPointerException - if the input or output is nulljava.io.IOException - if an I/O error occurspublic static long copyLarge(java.io.Reader input,
java.io.Writer output)
throws java.io.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 tojava.lang.NullPointerException - if the input or output is nulljava.io.IOException - if an I/O error occurspublic static long copyLarge(java.io.Reader input,
java.io.Writer output,
char[] buffer)
throws java.io.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 copyjava.lang.NullPointerException - if the input or output is nulljava.io.IOException - if an I/O error occurspublic static java.lang.String toString(java.io.Reader input)
throws java.io.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 fromjava.lang.NullPointerException - if the input is nulljava.io.IOException - if an I/O error occurs