Package blbutil
Class BGZIPOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- blbutil.BGZIPOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public final class BGZIPOutputStream extends java.io.OutputStreamClass
BGZIPOutputStreamis an output stream filter that performs BGZIP compression.The GZIP file format specification is described RFC 1952 and the BGZIP file format specification is described in the Sequence Alignment/Map Format Specification
Instances of class
BGZIPOutputStreamare not thread safe.
-
-
Constructor Summary
Constructors Constructor Description BGZIPOutputStream(java.io.OutputStream os, boolean writeEmptyBlock)Creates a newBGZIPOutputStreaminstance that writes to the specified output stream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidflush()static voidmain(java.lang.String[] args)Applies BGZIP compression on the specified files.voidwrite(byte[] ba)voidwrite(byte[] buf, int off, int len)voidwrite(int b)static voidwriteEmptyBlock(java.io.OutputStream os)Write an empty BGZIP block to the specified output stream.
-
-
-
Constructor Detail
-
BGZIPOutputStream
public BGZIPOutputStream(java.io.OutputStream os, boolean writeEmptyBlock)Creates a newBGZIPOutputStreaminstance that writes to the specified output stream.- Parameters:
os- the output streamwriteEmptyBlock-trueif theclose()method will write an empty BGZIP block to the end of the stream- Throws:
java.lang.NullPointerException- ifos == null
-
-
Method Detail
-
main
public static void main(java.lang.String[] args) throws java.io.IOExceptionApplies BGZIP compression on the specified files. The filename of each compressed file will be the original filename followed by ".gz". The original files are not deleted or overwritten. The program exits with an error message if any input filename ends with ".gz".- Parameters:
args- a list of files that will be compressed- Throws:
java.io.IOException- if an I/O error occurs
-
writeEmptyBlock
public static void writeEmptyBlock(java.io.OutputStream os) throws java.io.IOExceptionWrite an empty BGZIP block to the specified output stream. The Java Virtual Machine will exit with an error message if anIOExceptionis thrown while writing the empty BGZIP block.- Parameters:
os- the output stream- Throws:
java.io.IOException- if an I/O error occursjava.lang.NullPointerException- ifos == null
-
write
public void write(int b) throws java.io.IOException- Specified by:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] ba) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] buf, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.OutputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.OutputStream- Throws:
java.io.IOException
-
-