public final class IOUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.nio.file.LinkOption[] |
EMPTY_LINK_OPTIONS
Empty array of type
LinkOption. |
| Modifier and Type | Method and Description |
|---|---|
static void |
closeQuietly(java.io.Closeable c)
Deprecated.
|
static void |
copy(java.io.File sourceFile,
java.io.OutputStream outputStream)
Deprecated.
|
static long |
copy(java.io.InputStream input,
java.io.OutputStream output)
Deprecated.
|
static long |
copy(java.io.InputStream input,
java.io.OutputStream output,
int bufferSize)
Deprecated.
|
static long |
copyRange(java.io.InputStream input,
long len,
java.io.OutputStream output)
Deprecated.
|
static long |
copyRange(java.io.InputStream input,
long length,
java.io.OutputStream output,
int bufferSize)
Deprecated.
No longer used.
|
static int |
read(java.io.File file,
byte[] array)
Deprecated.
Use
Files.readAllBytes(java.nio.file.Path). |
static int |
readFully(java.io.InputStream input,
byte[] array)
Reads as much from input as possible to fill the given array.
|
static int |
readFully(java.io.InputStream input,
byte[] array,
int offset,
int length)
Reads as much from input as possible to fill the given array with the given amount of bytes.
|
static void |
readFully(java.nio.channels.ReadableByteChannel channel,
java.nio.ByteBuffer byteBuffer)
Reads
b.remaining() bytes from the given channel starting at the current channel's position. |
static byte[] |
readRange(java.io.InputStream input,
int length)
Gets part of the contents of an
InputStream as a byte[]. |
static byte[] |
readRange(java.nio.channels.ReadableByteChannel input,
int length)
Gets part of the contents of an
ReadableByteChannel as a byte[]. |
static long |
skip(java.io.InputStream input,
long toSkip)
Skips bytes from an input byte stream.
|
static byte[] |
toByteArray(java.io.InputStream input)
Deprecated.
|
public static final java.nio.file.LinkOption[] EMPTY_LINK_OPTIONS
LinkOption.@Deprecated public static void closeQuietly(java.io.Closeable c)
IOUtils.closeQuietly(Closeable).c - Closeable to close, can be null@Deprecated
public static void copy(java.io.File sourceFile,
java.io.OutputStream outputStream)
throws java.io.IOException
FileUtils.copyFile(File, OutputStream).sourceFile - The file to read.outputStream - The output stream to write.java.io.IOException - if an I/O error occurs when reading or writing.@Deprecated
public static long copy(java.io.InputStream input,
java.io.OutputStream output)
throws java.io.IOException
IOUtils.copy(InputStream, OutputStream).input - the InputStream to copyoutput - the target, may be null to simulate output to dev/null on Linux and NUL on Windowsjava.io.IOException - if an error occurs@Deprecated
public static long copy(java.io.InputStream input,
java.io.OutputStream output,
int bufferSize)
throws java.io.IOException
IOUtils.copy(InputStream, OutputStream, int).input - the InputStream to copyoutput - the target, may be null to simulate output to dev/null on Linux and NUL on WindowsbufferSize - the buffer size to use, must be bigger than 0java.io.IOException - if an error occursjava.lang.IllegalArgumentException - if bufferSize is smaller than or equal to 0@Deprecated
public static long copyRange(java.io.InputStream input,
long len,
java.io.OutputStream output)
throws java.io.IOException
IOUtils.copyLarge(InputStream, OutputStream, long, long).input - the InputStream to copyoutput - the target Streamlen - maximum amount of bytes to copyjava.io.IOException - if an error occurs@Deprecated
public static long copyRange(java.io.InputStream input,
long length,
java.io.OutputStream output,
int bufferSize)
throws java.io.IOException
input - the InputStream to copylength - maximum amount of bytes to copyoutput - the target, may be null to simulate output to dev/null on Linux and NUL on WindowsbufferSize - the buffer size to use, must be bigger than 0java.io.IOException - if an error occursjava.lang.IllegalArgumentException - if bufferSize is smaller than or equal to 0@Deprecated
public static int read(java.io.File file,
byte[] array)
throws java.io.IOException
Files.readAllBytes(java.nio.file.Path).This method may invoke read repeatedly to fill the array and only read less bytes than the length of the array if the end of the stream has been reached.
file - file to readarray - buffer to filljava.io.IOException - on errorpublic static int readFully(java.io.InputStream input,
byte[] array)
throws java.io.IOException
This method may invoke read repeatedly to fill the array and only read less bytes than the length of the array if the end of the stream has been reached.
input - stream to read fromarray - buffer to filljava.io.IOException - on errorpublic static int readFully(java.io.InputStream input,
byte[] array,
int offset,
int length)
throws java.io.IOException
This method may invoke read repeatedly to read the bytes and only read less bytes than the requested length if the end of the stream has been reached.
input - stream to read fromarray - buffer to filloffset - offset into the buffer to start filling atlength - of bytes to readjava.io.IOException - if an I/O error has occurredpublic static void readFully(java.nio.channels.ReadableByteChannel channel,
java.nio.ByteBuffer byteBuffer)
throws java.io.IOException
b.remaining() bytes from the given channel starting at the current channel's position.
This method reads repeatedly from the channel until the requested number of bytes are read. This method blocks until the requested number of bytes are read, the end of the channel is detected, or an exception is thrown.
channel - the channel to read frombyteBuffer - the buffer into which the data is read.java.io.IOException - if an I/O error occurs.java.io.EOFException - if the channel reaches the end before reading all the bytes.public static byte[] readRange(java.io.InputStream input,
int length)
throws java.io.IOException
InputStream as a byte[].input - the InputStream to read fromlength - maximum amount of bytes to copyjava.lang.NullPointerException - if the input is nulljava.io.IOException - if an I/O error occurspublic static byte[] readRange(java.nio.channels.ReadableByteChannel input,
int length)
throws java.io.IOException
ReadableByteChannel as a byte[].input - the ReadableByteChannel to read fromlength - maximum amount of bytes to copyjava.lang.NullPointerException - if the input is nulljava.io.IOException - if an I/O error occurspublic static long skip(java.io.InputStream input,
long toSkip)
throws java.io.IOException
This method will only skip less than the requested number of bytes if the end of the input stream has been reached.
input - stream to skip bytes intoSkip - the number of bytes to skipjava.io.IOException - on error@Deprecated
public static byte[] toByteArray(java.io.InputStream input)
throws java.io.IOException
IOUtils.toByteArray(InputStream).InputStream as a byte[].
This method buffers the input internally, so there is no need to use a BufferedInputStream.
input - the InputStream to read fromjava.lang.NullPointerException - if the input is nulljava.io.IOException - if an I/O error occursCopyright © 2010 - 2024 Adobe. All Rights Reserved