Package org.apache.pdfbox.pdfparser
Class EndstreamOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.BufferedOutputStream
org.apache.pdfbox.pdfparser.EndstreamOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
This class is only for the readUntilEndStream method, to prevent a
final CR LF or LF (but not a final CR!) from being written to the output,
unless the beginning of the stream is assumed to be ASCII.
Only the 3-param write() method is implemented. This solves
PDFBOX-2079 and PDFBOX-2120 and avoids making readUntilEndStream()
even more complex than it already is.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private boolean
private boolean
private int
Fields inherited from class java.io.BufferedOutputStream
buf, count
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.io.BufferedOutputStream
write
Methods inherited from class java.io.FilterOutputStream
close, write
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
hasCR
private boolean hasCR -
hasLF
private boolean hasLF -
pos
private int pos -
mustFilter
private boolean mustFilter
-
-
Constructor Details
-
EndstreamOutputStream
EndstreamOutputStream(OutputStream out)
-
-
Method Details
-
write
Write CR and/or LF that were kept, then writes len bytes from the specified byte array starting at offset off to this output stream, except trailing CR, CR LF, or LF. No filtering will be done for the entire stream if the beginning is assumed to be ASCII.- Overrides:
write
in classBufferedOutputStream
- Parameters:
b
- byte array.off
- offset.len
- length of segment to write.- Throws:
IOException
-
flush
write out a single CR if one was kept. Don't write kept CR LF or LF, and then call the base method to flush.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classBufferedOutputStream
- Throws:
IOException
-