Class StreamUtil
java.lang.Object
com.itextpdf.io.util.StreamUtil
This file is a helper class for internal usage only.
Be aware that its API and functionality may be changed in future.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcopyBytes(IRandomAccessSource source, long start, long length, OutputStream output) Copy bytes from theRandomAccessSourcetoOutputStream.static ByteBuffercreateBufferedEscapedString(byte[] bytes) static ByteBuffercreateBufferedHexedString(byte[] bytes) static byte[]createEscapedString(byte[] bytes) Escapes abytearray according to the PDF conventions.static byte[]inputStreamToArray(InputStream stream) Reads the full content of a stream and returns them in a byte arraystatic voidreadFully(InputStream input, byte[] b, int off, int len) Readslenbytes from an input stream.static voidskip(InputStream stream, long size) This method is an alternative for theInputStream.skip()-method that doesn't seem to work properly for big values ofsize.static voidtransferBytes(RandomAccessFileOrArray input, OutputStream output) static voidtransferBytes(InputStream input, OutputStream output) static voidwriteEscapedString(OutputStream outputStream, byte[] bytes) Escapes abytearray according to the PDF conventions.static voidwriteHexedString(OutputStream outputStream, byte[] bytes)
-
Field Details
-
TRANSFER_SIZE
private static final int TRANSFER_SIZE- See Also:
-
escR
private static final byte[] escR -
escN
private static final byte[] escN -
escT
private static final byte[] escT -
escB
private static final byte[] escB -
escF
private static final byte[] escF
-
-
Constructor Details
-
StreamUtil
private StreamUtil()
-
-
Method Details
-
skip
This method is an alternative for theInputStream.skip()-method that doesn't seem to work properly for big values ofsize.- Parameters:
stream- theInputStreamsize- the number of bytes to skip- Throws:
IOException- if an I/O error occurs.
-
createEscapedString
public static byte[] createEscapedString(byte[] bytes) Escapes abytearray according to the PDF conventions.- Parameters:
bytes- thebytearray to escape- Returns:
- an escaped
bytearray
-
writeEscapedString
Escapes abytearray according to the PDF conventions.- Parameters:
outputStream- theOutputStreaman escapedbytearray write to.bytes- thebytearray to escape.
-
writeHexedString
-
createBufferedEscapedString
-
createBufferedHexedString
-
transferBytes
- Throws:
IOException
-
transferBytes
public static void transferBytes(RandomAccessFileOrArray input, OutputStream output) throws IOException - Throws:
IOException
-
inputStreamToArray
Reads the full content of a stream and returns them in a byte array- Parameters:
stream- the stream to read- Returns:
- a byte array containing all of the bytes from the stream
- Throws:
IOException- if there is a problem reading from the input stream
-
copyBytes
public static void copyBytes(IRandomAccessSource source, long start, long length, OutputStream output) throws IOException Copy bytes from theRandomAccessSourcetoOutputStream.- Parameters:
source- theRandomAccessSourcecopy from.start- start position of source copy from.length- length copy to.output- theOutputStreamcopy to.- Throws:
IOException- on error.
-
readFully
Readslenbytes from an input stream.- Parameters:
input- the stream to readb- the buffer into which the data is read.off- an int specifying the offset into the data.len- an int specifying the number of bytes to read.- Throws:
IOException- if an I/O error occurs.
-