Class Writers


  • public final class Writers
    extends Object
    File and output stream writers with support for bgzf, gzip, and bzip2 compression.
    Author:
    Michael Heuer
    • Method Detail

      • bgzfOutputStreamWriter

        public static PrintWriter bgzfOutputStreamWriter​(OutputStream outputStream)
                                                  throws IOException
        Create and return a new buffered print writer with bgzf compression for the specified output stream.
        Parameters:
        outputStream - output stream, must not be null
        Returns:
        a new buffered print writer with bgzf compression for the specified output stream
        Throws:
        IOException - if an I/O error occurs
        Since:
        1.3
      • gzipOutputStreamWriter

        public static PrintWriter gzipOutputStreamWriter​(OutputStream outputStream)
                                                  throws IOException
        Create and return a new buffered print writer with gzip compression for the specified output stream.
        Parameters:
        outputStream - output stream, must not be null
        Returns:
        a new buffered print writer with gzip compression for the specified output stream
        Throws:
        IOException - if an I/O error occurs
      • bzip2OutputStreamWriter

        public static PrintWriter bzip2OutputStreamWriter​(OutputStream outputStream)
                                                   throws IOException
        Create and return a new buffered print writer with bzip2 compression for the specified output stream.
        Parameters:
        outputStream - output stream, must not be null
        Returns:
        a new buffered print writer with bzip2 compression for the specified output stream
        Throws:
        IOException - if an I/O error occurs
      • zstdOutputStreamWriter

        public static PrintWriter zstdOutputStreamWriter​(OutputStream outputStream)
                                                  throws IOException
        Create and return a new buffered print writer with Zstandard (zstd) compression for the specified output stream.
        Parameters:
        outputStream - output stream, must not be null
        Returns:
        a new buffered print writer with Zstandard (zstd) compression for the specified output stream
        Throws:
        IOException - if an I/O error occurs
        Since:
        1.4
      • writer

        public static PrintWriter writer​(@Nullable
                                         File file)
                                  throws IOException
        Create and return a new buffered print writer with support for bgzf, gzip, bzip2, or zstd compression for the specified file or stdout if the file is null.
        Parameters:
        file - file, if any
        Returns:
        a new buffered print writer with support for bgzf, gzip, bzip2, or zstd compression for the specified file or stdout if the file is null
        Throws:
        IOException - if an I/O error occurs
      • writer

        public static PrintWriter writer​(@Nullable
                                         File file,
                                         boolean append)
                                  throws IOException
        Create and return a new buffered print writer with support for bgzf, gzip, bzip2, or zstd compression for the specified file or stdout if the file is null.
        Parameters:
        file - file, if any
        append - true to append to the specified file
        Returns:
        a new buffered print writer with support for bgzf, gzip, bzip2, or zstd compression for the specified file or stdout if the file is null
        Throws:
        IOException - if an I/O error occurs