public final class IOUtils extends Object
Modifier and Type | Method and Description |
---|---|
static long |
calculateChecksum(byte[] data) |
static void |
closeQuietly(Closeable closeable)
Quietly (no exceptions) close Closable resource.
|
static void |
copy(InputStream inp,
OutputStream out)
Copies all the data from the given InputStream to the OutputStream.
|
static int |
readFully(InputStream in,
byte[] b)
Helper method, just calls readFully(in, b, 0, b.length)
|
static int |
readFully(InputStream in,
byte[] b,
int off,
int len)
Same as the normal in.read(b, off, len), but tries to ensure
that the entire len number of bytes is read.
|
static int |
readFully(ReadableByteChannel channel,
ByteBuffer b)
Same as the normal channel.read(b), but tries to ensure
that the entire len number of bytes is read.
|
static byte[] |
toByteArray(ByteBuffer buffer,
int length)
Returns an array (that shouldn't be written to!) of the
ByteBuffer.
|
static byte[] |
toByteArray(InputStream stream)
Reads all the data from the input stream, and returns the bytes read.
|
public static byte[] toByteArray(InputStream stream) throws IOException
IOException
public static byte[] toByteArray(ByteBuffer buffer, int length)
public static int readFully(InputStream in, byte[] b) throws IOException
IOException
public static int readFully(InputStream in, byte[] b, int off, int len) throws IOException
If the end of file is reached before any bytes are read, returns -1. If the end of the file is reached after some bytes are read, returns the number of bytes read. If the end of the file isn't reached before len bytes have been read, will return len bytes.
IOException
public static int readFully(ReadableByteChannel channel, ByteBuffer b) throws IOException
If the end of file is reached before any bytes are read, returns -1. If the end of the file is reached after some bytes are read, returns the number of bytes read. If the end of the file isn't reached before len bytes have been read, will return len bytes.
IOException
public static void copy(InputStream inp, OutputStream out) throws IOException
IOException
public static long calculateChecksum(byte[] data)
Copyright © 2020. All rights reserved.