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
-
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 TypeMethodDescriptionvoidclose()voidfinish()Finishes the addition of entries to this stream, without closing it.booleanisClosed()Tests whether this instance was successfully closed.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, writeMethods inherited from class java.io.OutputStream
nullOutputStream
-
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
-
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
public boolean isClosed()Tests whether this instance was successfully closed.- Returns:
- whether this instance was successfully closed.
- Since:
- 1.27.0
-
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:
-