|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.OutputStream htsjdk.samtools.util.BlockCompressedOutputStream
public class BlockCompressedOutputStream
Writer for a file that is a series of gzip blocks (BGZF format). The caller just treats it as an OutputStream, and under the covers a gzip block is written when the amount of uncompressed as-yet-unwritten bytes reaches a threshold. The advantage of BGZF over conventional gzip is that BGZF allows for seeking without having to scan through the entire file up to the position being sought. Note that the flush() method should not be called by client unless you know what you're doing, because it forces a gzip block to be written even if the number of buffered bytes has not reached threshold. close(), on the other hand, must be called when done writing in order to force the last gzip block to be written. c.f. http://samtools.sourceforge.net/SAM1.pdf for details of BGZF file format.
Constructor Summary | |
---|---|
BlockCompressedOutputStream(java.io.File file)
Uses default compression level, which is 5 unless changed by setDefaultCompressionLevel |
|
BlockCompressedOutputStream(java.io.File file,
int compressionLevel)
Prepare to compress at the given compression level |
|
BlockCompressedOutputStream(java.io.OutputStream os,
java.io.File file)
Constructors that take output streams file may be null |
|
BlockCompressedOutputStream(java.io.OutputStream os,
java.io.File file,
int compressionLevel)
|
|
BlockCompressedOutputStream(java.lang.String filename)
Uses default compression level, which is 5 unless changed by setDefaultCompressionLevel |
|
BlockCompressedOutputStream(java.lang.String filename,
int compressionLevel)
Prepare to compress at the given compression level |
Method Summary | |
---|---|
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()
|
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. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BlockCompressedOutputStream(java.lang.String filename)
public BlockCompressedOutputStream(java.io.File file)
public BlockCompressedOutputStream(java.lang.String filename, int compressionLevel)
compressionLevel
- 1 <= compressionLevel <= 9public BlockCompressedOutputStream(java.io.File file, int compressionLevel)
compressionLevel
- 1 <= compressionLevel <= 9public BlockCompressedOutputStream(java.io.OutputStream os, java.io.File file)
public BlockCompressedOutputStream(java.io.OutputStream os, java.io.File file, int compressionLevel)
Method Detail |
---|
public static void setDefaultCompressionLevel(int compressionLevel)
compressionLevel
- 1 <= compressionLevel <= 9public static int getDefaultCompressionLevel()
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 data
java.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 write
java.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 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
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |