Package blbutil

Class 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 new BGZIPOutputStream 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.
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BGZIPOutputStream

        public BGZIPOutputStream​(java.io.OutputStream os,
                                 boolean writeEmptyBlock)
        Creates a new BGZIPOutputStream instance that writes to the specified output stream.
        Parameters:
        os - the output stream
        writeEmptyBlock - true if the close() method will write an empty BGZIP block to the end of the stream
        Throws:
        java.lang.NullPointerException - if os == 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 an IOException is thrown while writing the empty BGZIP block.
        Parameters:
        os - the output stream
        Throws:
        java.io.IOException - if an I/O error occurs
        java.lang.NullPointerException - if os == null
      • write

        public void write​(int b)
                   throws java.io.IOException
        Specified by:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] ba)
                   throws java.io.IOException
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] buf,
                          int off,
                          int len)
                   throws java.io.IOException
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.OutputStream
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.OutputStream
        Throws:
        java.io.IOException