Package org.apache.commons.compress
Class CompressFilterOutputStream<T extends OutputStream>
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.apache.commons.compress.CompressFilterOutputStream<T>
- Type Parameters:
T- The underlyingOutputStreamtype.
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
- Direct Known Subclasses:
ArchiveOutputStream,CompressorOutputStream
Abstracts classes that compress or archive an output stream.
- Since:
- 1.28.0
-
Field Summary
Fields inherited from class java.io.FilterOutputStream
out -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance without a backingOutputStream.Creates an output stream filter built on top of the specified underlyingOutputStream. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCheck to make sure that this stream has not been closed.voidclose()voidfinish()Finishes the addition of entries to this stream, without closing it.booleanisClosed()Tests whether this instance was successfully closed.protected booleanTests whether this instance was successfully finished.protected Tout()Gets the underlying output stream.longWrites all bytes from a file this output stream.longWrites all bytes from a file to this output stream.byte[]writeUsAscii(String data) Writes and filters the ASCII bytes from the specified String to this output stream.byte[]writeUsAsciiRaw(String data) Writes the raw ASCII bytes from the specified String to this output stream.byte[]Writes and filters the UTF-8 bytes from the specified String to this output stream.Methods inherited from class java.io.FilterOutputStream
flush, write, write, write
-
Constructor Details
-
CompressFilterOutputStream
public CompressFilterOutputStream()Constructs a new instance without a backingOutputStream.You must initialize
this.outafter construction. -
CompressFilterOutputStream
Creates an output stream filter built on top of the specified underlyingOutputStream.- Parameters:
out- the underlying output stream to be assigned to the fieldthis.outfor later use, ornullif this instance is to be created without an underlying stream.
-
-
Method Details
-
checkOpen
Check to make sure that this stream has not been closed.- Throws:
IOException- if the stream is already closed.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterOutputStream- Throws:
IOException
-
finish
Finishes the addition of entries to this stream, without closing it. Additional data can be written, if the format supports it.- Throws:
IOException- Maybe thrown by subclasses if the user forgets to close the entry.
-
isClosed
Tests whether this instance was successfully closed.- Returns:
- whether this instance was successfully closed.
- Since:
- 1.27.0
-
isFinished
Tests whether this instance was successfully finished.- Returns:
- whether this instance was successfully finished.
- Since:
- 1.27.0
-
out
Gets the underlying output stream.- Returns:
- the underlying output stream.
-
write
Writes all bytes from a file this output stream.- Parameters:
file- the path to the source file.- Returns:
- the number of bytes read or written.
- Throws:
IOException- if an I/O error occurs when reading or writing.
-
write
Writes all bytes from a file to this output stream.- Parameters:
path- the path to the source file.- Returns:
- the number of bytes read or written.
- Throws:
IOException- if an I/O error occurs when reading or writing.
-
writeUsAscii
Writes and filters the ASCII bytes from the specified String to this output stream.- Parameters:
data- the data.- Returns:
- the ASCII bytes.
- Throws:
IOException- if an I/O error occurs.- See Also:
-
writeUsAsciiRaw
Writes the raw ASCII bytes from the specified String to this output stream.- Parameters:
data- the data.- Returns:
- the ASCII bytes.
- Throws:
IOException- if an I/O error occurs.- See Also:
-
writeUtf8
Writes and filters the UTF-8 bytes from the specified String to this output stream.- Parameters:
data- the data.- Returns:
- the ASCII bytes.
- Throws:
IOException- if an I/O error occurs.- See Also:
-