Package org.apache.pdfbox.io
Class IOUtils
- java.lang.Object
-
- org.apache.pdfbox.io.IOUtils
-
public class IOUtils extends java.lang.ObjectThis class contains various I/O-related methods.- Version:
- $Revision$
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcloseQuietly(java.io.InputStream input)Unconditionally close anInputStream.static voidcloseQuietly(java.io.OutputStream output)Unconditionally close anOutputStream.static voidcloseQuietly(java.io.Reader input)Unconditionally close anReader.static voidcloseQuietly(java.io.Writer output)Unconditionally close aWriter.static longcopy(java.io.InputStream input, java.io.OutputStream output)Copies all the contents from the given input stream to the given output stream.static longpopulateBuffer(java.io.InputStream in, byte[] buffer)Populates the given buffer with data read from the input stream.static byte[]toByteArray(java.io.InputStream in)Reads the input stream and returns its contents as a byte array.
-
-
-
Method Detail
-
toByteArray
public static byte[] toByteArray(java.io.InputStream in) throws java.io.IOExceptionReads the input stream and returns its contents as a byte array.- Parameters:
in- the input stream to read from.- Returns:
- the byte array
- Throws:
java.io.IOException- if an I/O error occurs
-
copy
public static long copy(java.io.InputStream input, java.io.OutputStream output) throws java.io.IOExceptionCopies 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:
java.io.IOException- if an I/O error occurs
-
populateBuffer
public static long populateBuffer(java.io.InputStream in, byte[] buffer) throws java.io.IOExceptionPopulates 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:
java.io.IOException- if an I/O error occurs
-
closeQuietly
public static void closeQuietly(java.io.InputStream input)
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
public static void closeQuietly(java.io.Reader input)
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
public static void closeQuietly(java.io.Writer output)
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
public static void closeQuietly(java.io.OutputStream output)
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
-
-