Class IOUtils
java.lang.Object
org.apache.logging.log4j.core.util.IOUtils
Copied from Apache Commons IO revision 1686747.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
Copies chars from aReader
to aWriter
.static long
Copies chars from a large (over 2GB)Reader
to aWriter
.static long
Copies chars from a large (over 2GB)Reader
to aWriter
.static String
Gets the contents of aReader
as a String.
-
Field Details
-
EOF
public static final int EOFRepresents the end-of-file (or stream).- See Also:
-
-
Constructor Details
-
IOUtils
public IOUtils()
-
-
Method Details
-
copy
Copies chars from aReader
to aWriter
.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 thecopyLarge(Reader, Writer)
method.- Parameters:
input
- theReader
to read fromoutput
- theWriter
to write to- Returns:
- the number of characters copied, or -1 if > Integer.MAX_VALUE
- Throws:
NullPointerException
- if the input or output is nullIOException
- if an I/O error occurs- Since:
- 1.1
-
copyLarge
Copies chars from a large (over 2GB)Reader
to aWriter
.This method buffers the input internally, so there is no need to use a
BufferedReader
.The buffer size is given by
DEFAULT_BUFFER_SIZE
.- Parameters:
input
- theReader
to read fromoutput
- theWriter
to write to- Returns:
- the number of characters copied
- Throws:
NullPointerException
- if the input or output is nullIOException
- if an I/O error occurs- Since:
- 1.3
-
copyLarge
Copies chars from a large (over 2GB)Reader
to aWriter
.This method uses the provided buffer, so there is no need to use a
BufferedReader
.- Parameters:
input
- theReader
to read fromoutput
- theWriter
to write tobuffer
- the buffer to be used for the copy- Returns:
- the number of characters copied
- Throws:
NullPointerException
- if the input or output is nullIOException
- if an I/O error occurs- Since:
- 2.2
-
toString
Gets the contents of aReader
as a String.This method buffers the input internally, so there is no need to use a
BufferedReader
.- Parameters:
input
- theReader
to read from- Returns:
- the requested String
- Throws:
NullPointerException
- if the input is nullIOException
- if an I/O error occurs
-