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.OutputStream
Class
BGZIPOutputStream
is 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
BGZIPOutputStream
are not thread safe.
-
-
Constructor Summary
Constructors Constructor Description BGZIPOutputStream(java.io.OutputStream os, boolean writeEmptyBlock)
Creates a newBGZIPOutputStream
instance that writes to the specified output stream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
static void
main(java.lang.String[] args)
Applies BGZIP compression on the specified files.void
write(byte[] ba)
void
write(byte[] buf, int off, int len)
void
write(int b)
static void
writeEmptyBlock(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 newBGZIPOutputStream
instance that writes to the specified output stream.- Parameters:
os
- the output streamwriteEmptyBlock
-true
if 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.IOException
Applies 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.IOException
Write an empty BGZIP block to the specified output stream. The Java Virtual Machine will exit with an error message if anIOException
is 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:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] ba) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] buf, int off, int len) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
-