Package com.pdftools.sys
Interface Stream
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
FileStream,MemoryStream
The unified stream interface for reading and writing data.
Java's stream interfaces cannot be used, because they are lacking two important features:
- The PDF file format is based on random access. Java streams have only limited support for this.
- The ability to read from an output stream is crucial for processing large PDF files.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the stream and release all associated resources.longGet the length of the stream in bytesintread(byte[] buffer, int offset, int length) Read from the streambooleanseek(long position) Set byte positionlongtell()Get current byte positionvoidwrite(byte[] buffer, int offset, int length) Write to the stream
-
Method Details
-
getLength
Get the length of the stream in bytes- Returns:
- the length of the stream in bytes
- Throws:
IOException
-
seek
Set byte position- Parameters:
position- The new position of the stream (-1 for EOS)- Returns:
- true if successful
- Throws:
IOException
-
tell
Get current byte position- Returns:
- byte position, -1 if position unknown
- Throws:
IOException
-
read
Read from the stream- Parameters:
buffer- The buffer where the data is writtenoffset- The starting element in the bufferlength- The maximum number of bytes to be read- Returns:
- The actual number of bytes read (-1 if EOS)
- Throws:
IOException
-
write
Write to the stream- Parameters:
buffer- The buffer where the data liesoffset- The starting element in the bufferlength- The maximum number of bytes to write- Throws:
IOException
-
close
Close the stream and release all associated resources.- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-