FileCopyUtils except that all affected streams are
left open when done. All copy methods use a block size of 8192 bytes.
Mainly for use within the framework, but also useful for application code.
FileCopyUtils
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| public static final int | BUFFER_SIZE
The default buffer size used when copying bytes. |
| private static final byte[] |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static void | copy(byte[]
the byte array to copy from in, OutputStream the OutputStream to copy to out)Copy the contents of the given byte array to the given OutputStream. |
| public static void | copy(String
the String to copy from in, Charset the Charset charset, OutputStream the OutputStream to copy to out)Copy the contents of the given String to the given OutputStream. |
| public static int | Returns: the number of bytes copiedthe InputStream to copy from in, OutputStream the OutputStream to copy to out)Copy the contents of the given InputStream to the given OutputStream. |
| public static long | Returns: the number of bytes copiedthe InputStream to copy from in, OutputStream the OutputStream to copy to out, long the position to start copying from start, long the position to end copying end)Copy a range of content of the given InputStream to the given OutputStream. |
| public static byte[] | Returns: the new byte array that has been copied to (possibly empty)the stream to copy from (may be in)null or empty)Copy the contents of the given InputStream into a new byte array. |
| public static String | Returns: the String that has been copied to (possibly empty)the InputStream to copy from (may be in, Charset null or empty)the charset)Charset to use to decode the bytesCopy the contents of the given InputStream into a String. |
| public static String | Returns: the String that has been copied to (possibly empty)the baos, Charset ByteArrayOutputStream to be copied into a Stringthe charset)Charset to use to decode the bytesCopy the contents of the given |
| public static int | Returns: the number of bytes readthe InputStream to drain in)Drain the remaining content of the given InputStream. |
| public static InputStream | Returns: an InputStream which contains no bytes
Deprecated
since 6.0. as of 6.0 in favor of
Return an efficient empty InputStream#nullInputStream()
InputStream.
|
| public static InputStream | Returns: a version of the InputStream that ignores calls to closethe InputStream to decorate in)Return a variant of the given |
| public static OutputStream | Returns: a version of the OutputStream that ignores calls to closethe OutputStream to decorate out)Return a variant of the given |
| BUFFER_SIZE | back to summary |
|---|---|
| public static final int BUFFER_SIZE The default buffer size used when copying bytes. | |
| EMPTY_CONTENT | back to summary |
|---|---|
| private static final byte[] EMPTY_CONTENT | |
| StreamUtils | back to summary |
|---|---|
| public StreamUtils() | |
| copy | back to summary |
|---|---|
| public static void copy(byte[] in, OutputStream out) throws IOException Copy the contents of the given byte array to the given OutputStream. Leaves the stream open when done.
| |
| copy | back to summary |
|---|---|
| public static void copy(String in, Charset charset, OutputStream out) throws IOException Copy the contents of the given String to the given OutputStream. Leaves the stream open when done.
| |
| copy | back to summary |
|---|---|
| public static int copy(InputStream in, OutputStream out) throws IOException Copy the contents of the given InputStream to the given OutputStream. Leaves both streams open when done.
| |
| copyRange | back to summary |
|---|---|
| public static long copyRange(InputStream in, OutputStream out, long start, long end) throws IOException Copy a range of content of the given InputStream to the given OutputStream. If the specified range exceeds the length of the InputStream, this copies up to the end of the stream and returns the actual number of copied bytes. Leaves both streams open when done.
| |
| copyToByteArray | back to summary |
|---|---|
| public static byte[] copyToByteArray(InputStream in) throws IOException Copy the contents of the given InputStream into a new byte array. Leaves the stream open when done.
| |
| copyToString | back to summary |
|---|---|
| public static String copyToString(InputStream in, Charset charset) throws IOException Copy the contents of the given InputStream into a String. Leaves the stream open when done.
| |
| copyToString | back to summary |
|---|---|
| public static String copyToString(ByteArrayOutputStream baos, Charset charset) Copy the contents of the given This is a more effective equivalent of
| |
| drain | back to summary |
|---|---|
| public static int drain(InputStream in) throws IOException Drain the remaining content of the given InputStream. Leaves the InputStream open when done.
| |
| emptyInput | back to summary |
|---|---|
| public static InputStream emptyInput()
Return an efficient empty
| |
| nonClosing | back to summary |
|---|---|
| public static InputStream nonClosing(InputStream in) Return a variant of the given
| |
| nonClosing | back to summary |
|---|---|
| public static OutputStream nonClosing(OutputStream out) Return a variant of the given
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Overrides java. Implements java. |
| NonClosingInputStream | back to summary |
|---|---|
| public NonClosingInputStream(InputStream in) | |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this input stream and releases any system resources associated with the stream.
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Overrides java. Implements java. |
| public void | write(byte[]
the data. b, int the start offset in the data. off, int the number of bytes to write. let)Overrides java. len bytes from the specified
byte array starting at offset off to
this output stream.
|
| NonClosingOutputStream | back to summary |
|---|---|
| public NonClosingOutputStream(OutputStream out) | |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this output stream and releases any system resources associated with the stream.
| |
| write | back to summary |
|---|---|
| public void write(byte[] b, int off, int let) throws IOException Overrides java. Doc from java. Writes
| |