Package org.apache.pdfbox.io
Class RandomAccessFileOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.pdfbox.io.RandomAccessFileOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class RandomAccessFileOutputStream extends java.io.OutputStream
This will write to a RandomAccessFile in the filesystem and keep track of the position it is writing to and the length of the stream.- Version:
- $Revision: 1.6 $
- Author:
- Ben Litchfield
-
-
Constructor Summary
Constructors Constructor Description RandomAccessFileOutputStream(RandomAccess raf)
Constructor to create an output stream that will write to the end of a random access file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description COSBase
getExpectedLength()
This will get the length that the PDF document specified this stream should be.long
getLength()
The number of bytes written or expected in the stream.long
getLengthWritten()
Get the amount of data that was actually written to the stream, in theory this should be the same as the length specified but in some cases it doesn't match.long
getPosition()
This will get the position in the RAF that the stream was written to.void
setExpectedLength(COSBase value)
This will set the expected length of this stream.void
write(byte[] b, int offset, int length)
void
write(int b)
-
-
-
Constructor Detail
-
RandomAccessFileOutputStream
public RandomAccessFileOutputStream(RandomAccess raf) throws java.io.IOException
Constructor to create an output stream that will write to the end of a random access file.- Parameters:
raf
- The file to write to.- Throws:
java.io.IOException
- If there is a problem accessing the raf.
-
-
Method Detail
-
getPosition
public long getPosition()
This will get the position in the RAF that the stream was written to.- Returns:
- The position in the raf where the file can be obtained.
-
getLengthWritten
public long getLengthWritten()
Get the amount of data that was actually written to the stream, in theory this should be the same as the length specified but in some cases it doesn't match.- Returns:
- The number of bytes actually written to this stream.
-
getLength
public long getLength()
The number of bytes written or expected in the stream.- Returns:
- The number of bytes written or expected in the stream.
-
write
public void write(byte[] b, int offset, int length) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(int b) throws java.io.IOException
- Specified by:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
getExpectedLength
public COSBase getExpectedLength()
This will get the length that the PDF document specified this stream should be. This may not match the number of bytes read.- Returns:
- The expected length.
-
setExpectedLength
public void setExpectedLength(COSBase value)
This will set the expected length of this stream.- Parameters:
value
- The expected value.
-
-