Class IOUtils
- java.lang.Object
-
- org.apache.logging.log4j.core.util.IOUtils
-
public class IOUtils extends java.lang.ObjectCopied from Apache Commons IO revision 1686747.
-
-
Field Summary
Fields Modifier and Type Field Description private static intDEFAULT_BUFFER_SIZEThe default buffer size (4096) to use for#copyLarge(InputStream, OutputStream)andcopyLarge(Reader, Writer)static intEOFRepresents the end-of-file (or stream).
-
Constructor Summary
Constructors Constructor Description IOUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcopy(java.io.Reader input, java.io.Writer output)Copies chars from aReaderto aWriter.static longcopyLarge(java.io.Reader input, java.io.Writer output)Copies chars from a large (over 2GB)Readerto aWriter.static longcopyLarge(java.io.Reader input, java.io.Writer output, char[] buffer)Copies chars from a large (over 2GB)Readerto aWriter.static java.lang.StringtoString(java.io.Reader input)Gets the contents of aReaderas a String.
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
private static final int DEFAULT_BUFFER_SIZE
The default buffer size (4096) to use for#copyLarge(InputStream, OutputStream)andcopyLarge(Reader, Writer)- See Also:
- Constant Field Values
-
EOF
public static final int EOF
Represents the end-of-file (or stream).- See Also:
- Constant Field Values
-
-
Method Detail
-
copy
public static int copy(java.io.Reader input, java.io.Writer output) throws java.io.IOExceptionCopies chars from aReaderto aWriter. This method buffers the input internally, so there is no need to use aBufferedReader. Large streams (over 2GB) will return a chars copied value of-1after 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- theReaderto read fromoutput- theWriterto write to- Returns:
- the number of characters copied, or -1 if > Integer.MAX_VALUE
- Throws:
java.lang.NullPointerException- if the input or output is nulljava.io.IOException- if an I/O error occurs- Since:
- 1.1
-
copyLarge
public static long copyLarge(java.io.Reader input, java.io.Writer output) throws java.io.IOExceptionCopies chars from a large (over 2GB)Readerto aWriter. This method buffers the input internally, so there is no need to use aBufferedReader. The buffer size is given byDEFAULT_BUFFER_SIZE.- Parameters:
input- theReaderto read fromoutput- theWriterto write to- Returns:
- the number of characters copied
- Throws:
java.lang.NullPointerException- if the input or output is nulljava.io.IOException- if an I/O error occurs- Since:
- 1.3
-
copyLarge
public static long copyLarge(java.io.Reader input, java.io.Writer output, char[] buffer) throws java.io.IOExceptionCopies chars from a large (over 2GB)Readerto aWriter. This method uses the provided buffer, so there is no need to use aBufferedReader.- Parameters:
input- theReaderto read fromoutput- theWriterto write tobuffer- the buffer to be used for the copy- Returns:
- the number of characters copied
- Throws:
java.lang.NullPointerException- if the input or output is nulljava.io.IOException- if an I/O error occurs- Since:
- 2.2
-
toString
public static java.lang.String toString(java.io.Reader input) throws java.io.IOExceptionGets the contents of aReaderas a String. This method buffers the input internally, so there is no need to use aBufferedReader.- Parameters:
input- theReaderto read from- Returns:
- the requested String
- Throws:
java.lang.NullPointerException- if the input is nulljava.io.IOException- if an I/O error occurs
-
-