Package com.tom_roush.pdfbox.io
Class IOUtils
- java.lang.Object
-
- com.tom_roush.pdfbox.io.IOUtils
-
public final class IOUtils extends Object
This class contains various I/O-related methods.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcloseQuietly(Closeable closeable)Null safe close of the givenCloseablesuppressing any exception.static longcopy(InputStream input, OutputStream output)Copies all the contents from the given input stream to the given output stream.static longpopulateBuffer(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.
-
-
-
Method Detail
-
toByteArray
public static byte[] toByteArray(InputStream in) throws IOException
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
public static long copy(InputStream input, OutputStream output) throws IOException
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
public static long populateBuffer(InputStream in, byte[] buffer) throws IOException
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
-
-