public class IOUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
closeQuietly(InputStream input)
Unconditionally close an
InputStream . |
static void |
closeQuietly(OutputStream output)
Unconditionally close an
OutputStream . |
static void |
closeQuietly(Reader input)
Unconditionally close an
Reader . |
static void |
closeQuietly(Writer output)
Unconditionally close a
Writer . |
static long |
copy(InputStream input,
OutputStream output)
Copies all the contents from the given input stream to the given output stream.
|
static long |
populateBuffer(InputStream in,
byte[] buffer)
Populates the given buffer with data read from the input stream.
|
static byte[] |
toByteArray(InputStream in)
Reads the input stream and returns its contents as a byte array.
|
public static byte[] toByteArray(InputStream in) throws IOException
in
- the input stream to read from.IOException
- if an I/O error occurspublic static long copy(InputStream input, OutputStream output) throws IOException
input
- the input streamoutput
- the output streamIOException
- if an I/O error occurspublic static long populateBuffer(InputStream in, byte[] buffer) throws IOException
in
- the input stream to read frombuffer
- the buffer to fillIOException
- if an I/O error occurspublic static void closeQuietly(InputStream input)
InputStream
.
Equivalent to InputStream.close()
, except any exceptions will be ignored.
This is typically used in finally blocks.
input
- the InputStream to close, may be null or already closedpublic static void closeQuietly(Reader input)
Reader
.
Equivalent to Reader.close()
, except any exceptions will be ignored.
This is typically used in finally blocks.
input
- the Reader to close, may be null or already closedpublic static void closeQuietly(Writer output)
Writer
.
Equivalent to Writer.close()
, except any exceptions will be ignored.
This is typically used in finally blocks.
output
- the Writer to close, may be null or already closedpublic static void closeQuietly(OutputStream output)
OutputStream
.
Equivalent to OutputStream.close()
, except any exceptions will be ignored.
This is typically used in finally blocks.
output
- the OutputStream to close, may be null or already closedCopyright © 2002–2017 The Apache Software Foundation. All rights reserved.