public class BlockCompressedOutputStream extends java.io.OutputStream implements LocationAware
Constructor and Description |
---|
BlockCompressedOutputStream(java.io.File file)
Uses default compression level, which is 5 unless changed by setCompressionLevel
Note: this constructor uses the default
DeflaterFactory , see getDefaultDeflaterFactory() . |
BlockCompressedOutputStream(java.io.File file,
int compressionLevel)
Prepare to compress at the given compression level
|
BlockCompressedOutputStream(java.io.File file,
int compressionLevel,
DeflaterFactory deflaterFactory)
Prepare to compress at the given compression level
|
BlockCompressedOutputStream(java.io.OutputStream os,
java.io.File file)
Uses default compression level, which is 5 unless changed by setCompressionLevel
Note: this constructor uses the default
DeflaterFactory , see getDefaultDeflaterFactory() . |
BlockCompressedOutputStream(java.io.OutputStream os,
java.io.File file,
int compressionLevel)
Note: this constructor uses the default
DeflaterFactory , see getDefaultDeflaterFactory() . |
BlockCompressedOutputStream(java.io.OutputStream os,
java.io.File file,
int compressionLevel,
DeflaterFactory deflaterFactory)
Creates the output stream.
|
BlockCompressedOutputStream(java.lang.String filename)
Uses default compression level, which is 5 unless changed by setCompressionLevel
Note: this constructor uses the default
DeflaterFactory , see getDefaultDeflaterFactory() . |
BlockCompressedOutputStream(java.lang.String filename,
int compressionLevel)
Prepare to compress at the given compression level
Note: this constructor uses the default
DeflaterFactory , see getDefaultDeflaterFactory() . |
Modifier and Type | Method and Description |
---|---|
void |
close()
close() must be called in order to flush any remaining buffered bytes.
|
void |
flush()
WARNING: flush() affects the output format, because it causes the current contents of uncompressedBuffer
to be compressed and written, even if it isn't full.
|
static int |
getDefaultCompressionLevel() |
static DeflaterFactory |
getDefaultDeflaterFactory() |
long |
getFilePointer()
Encode virtual file pointer
Upper 48 bits is the byte offset into the compressed stream of a block.
|
long |
getPosition()
The current offset, in bytes, of this stream/writer/file.
|
static BlockCompressedOutputStream |
maybeBgzfWrapOutputStream(java.io.File location,
java.io.OutputStream output) |
static void |
setDefaultCompressionLevel(int compressionLevel)
Sets the GZip compression level for subsequent BlockCompressedOutputStream object creation
that do not specify the compression level.
|
static void |
setDefaultDeflaterFactory(DeflaterFactory deflaterFactory)
Sets the default
DeflaterFactory that will be used for all instances unless specified otherwise in the constructor. |
void |
write(byte[] bytes)
Writes b.length bytes from the specified byte array to this output stream.
|
void |
write(byte[] bytes,
int startIndex,
int numBytes)
Writes len bytes from the specified byte array starting at offset off to this output stream.
|
void |
write(int bite)
Writes the specified byte to this output stream.
|
public BlockCompressedOutputStream(java.lang.String filename)
DeflaterFactory
, see getDefaultDeflaterFactory()
.
Use BlockCompressedOutputStream(File, int, DeflaterFactory)
to specify a custom factory.public BlockCompressedOutputStream(java.io.File file)
DeflaterFactory
, see getDefaultDeflaterFactory()
.
Use BlockCompressedOutputStream(File, int, DeflaterFactory)
to specify a custom factory.public BlockCompressedOutputStream(java.lang.String filename, int compressionLevel)
DeflaterFactory
, see getDefaultDeflaterFactory()
.compressionLevel
- 1 <= compressionLevel <= 9public BlockCompressedOutputStream(java.io.File file, int compressionLevel)
compressionLevel
- 1 <= compressionLevel <= 9
Note: this constructor uses the default DeflaterFactory
, see getDefaultDeflaterFactory()
.
Use BlockCompressedOutputStream(File, int, DeflaterFactory)
to specify a custom factory.public BlockCompressedOutputStream(java.io.File file, int compressionLevel, DeflaterFactory deflaterFactory)
compressionLevel
- 1 <= compressionLevel <= 9deflaterFactory
- custom factory to create deflaters (overrides the default)public BlockCompressedOutputStream(java.io.OutputStream os, java.io.File file)
DeflaterFactory
, see getDefaultDeflaterFactory()
.
Use BlockCompressedOutputStream(OutputStream, File, int, DeflaterFactory)
to specify a custom factory.file
- may be nullpublic BlockCompressedOutputStream(java.io.OutputStream os, java.io.File file, int compressionLevel)
DeflaterFactory
, see getDefaultDeflaterFactory()
.
Use BlockCompressedOutputStream(OutputStream, File, int, DeflaterFactory)
to specify a custom factory.public BlockCompressedOutputStream(java.io.OutputStream os, java.io.File file, int compressionLevel, DeflaterFactory deflaterFactory)
os
- output stream to create a BlockCompressedOutputStream fromfile
- file to which to write the output or null if not availablecompressionLevel
- the compression level (0-9)deflaterFactory
- custom factory to create deflaters (overrides the default)public static void setDefaultCompressionLevel(int compressionLevel)
compressionLevel
- 1 <= compressionLevel <= 9public static int getDefaultCompressionLevel()
public static void setDefaultDeflaterFactory(DeflaterFactory deflaterFactory)
DeflaterFactory
that will be used for all instances unless specified otherwise in the constructor.
If this method is not called the default is a factory that will create the JDK Deflater
.deflaterFactory
- non-null default factory.public static DeflaterFactory getDefaultDeflaterFactory()
public static BlockCompressedOutputStream maybeBgzfWrapOutputStream(java.io.File location, java.io.OutputStream output)
location
- May be null. Used for error messages, and for checking file termination.output
- May or not already be a BlockCompressedOutputStream.public void write(byte[] bytes) throws java.io.IOException
write
in class java.io.OutputStream
bytes
- the datajava.io.IOException
public void write(byte[] bytes, int startIndex, int numBytes) throws java.io.IOException
write
in class java.io.OutputStream
bytes
- the datastartIndex
- the start offset in the datanumBytes
- the number of bytes to writejava.io.IOException
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.OutputStream
java.io.IOException
public void write(int bite) throws java.io.IOException
write
in class java.io.OutputStream
bite
- java.io.IOException
public long getFilePointer()
public long getPosition()
LocationAware
getPosition
in interface LocationAware