public class IOUtil extends Object
Modifier and Type | Field and Description |
---|---|
static int |
IO_COPY_BUFFER_SIZE |
Constructor and Description |
---|
IOUtil() |
Modifier and Type | Method and Description |
---|---|
protected static int |
calcNewNrReadSize(int nrRead,
int totalNrNread)
if totalNrRead < 0 then totalNrRead is returned, if (nrRead + totalNrRead) < Integer.MAX_VALUE then nrRead + totalNrRead is returned, -1 otherwise.
|
static int |
copy(InputStream in,
OutputStream out)
Copies the contents of the InputStream to the OutputStream.
|
static int |
copy(Reader in,
Writer out)
Copies the contents of the Reader to the Writer.
|
static byte[] |
toByteArray(InputStream in)
Returns the contents of the InputStream as a byte[]
|
static byte[] |
toByteArray(InputStream in,
int size)
Reads data from the InputStream, using the specified buffer size.
|
static byte[] |
toByteArray(Reader in,
String encoding)
Gets the contents of the Reader as a byte[], with the given character encoding.
|
public static final int IO_COPY_BUFFER_SIZE
public static byte[] toByteArray(Reader in, String encoding) throws IOException
in
- encoding
- IOException
public static byte[] toByteArray(InputStream in) throws IOException
in
- IOException
public static byte[] toByteArray(InputStream in, int size) throws IOException
in
- the stream to read data fromsize
- the size of the array to createIOException
protected static int calcNewNrReadSize(int nrRead, int totalNrNread)
nrRead
- totalNrNread
- public static int copy(InputStream in, OutputStream out) throws IOException
in
- out
- IOException
public static int copy(Reader in, Writer out) throws IOException
in
- out
- IOException
Copyright © 2009–2017. All rights reserved.