Package org.apache.pdfbox.io
Class IOUtils
java.lang.Object
org.apache.pdfbox.io.IOUtils
This class contains various I/O-related methods.
- Version:
- $Revision$
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
closeQuietly
(InputStream input) Unconditionally close anInputStream
.static void
closeQuietly
(OutputStream output) Unconditionally close anOutputStream
.static void
closeQuietly
(Reader input) Unconditionally close anReader
.static void
closeQuietly
(Writer output) Unconditionally close aWriter
.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[]
Reads the input stream and returns its contents as a byte array.
-
Method Details
-
toByteArray
Reads the input stream and returns its contents as a byte array.- Parameters:
in
- the input stream to read from.- Returns:
- the byte array
- Throws:
IOException
- if an I/O error occurs
-
copy
Copies all the contents from the given input stream to the given output stream.- Parameters:
input
- the input streamoutput
- the output stream- Returns:
- the number of bytes that have been copied
- Throws:
IOException
- if an I/O error occurs
-
populateBuffer
Populates the given buffer with data read from the input stream. If the data doesn't fit the buffer, only the data that fits in the buffer is read. If the data is less than fits in the buffer, the buffer is not completely filled.- Parameters:
in
- the input stream to read frombuffer
- the buffer to fill- Returns:
- the number of bytes written to the buffer
- Throws:
IOException
- if an I/O error occurs
-
closeQuietly
Unconditionally close anInputStream
.Equivalent to
InputStream.close()
, except any exceptions will be ignored. This is typically used in finally blocks.- Parameters:
input
- the InputStream to close, may be null or already closed
-
closeQuietly
Unconditionally close anReader
.Equivalent to
Reader.close()
, except any exceptions will be ignored. This is typically used in finally blocks.- Parameters:
input
- the Reader to close, may be null or already closed
-
closeQuietly
Unconditionally close aWriter
.Equivalent to
Writer.close()
, except any exceptions will be ignored. This is typically used in finally blocks.- Parameters:
output
- the Writer to close, may be null or already closed
-
closeQuietly
Unconditionally close anOutputStream
.Equivalent to
OutputStream.close()
, except any exceptions will be ignored. This is typically used in finally blocks.- Parameters:
output
- the OutputStream to close, may be null or already closed
-