@@ -0,0 +1,1836 @@
+package gngs;%0A%0Aimport java.io.IOException;%0Aimport java.io.OutputStream;%0Aimport java.io.Writer;%0A%0Aimport htsjdk.samtools.util.StringUtil;%0A%0A/**%0A * %0A * Copied from HTSJDK but with constructor modified so that the buffer size can be customized%0A * %0A * Fast (I hope) buffered Writer that converts char to byte merely by casting, rather than charset conversion.%0A */%0Apublic final class AsciiWriter extends Writer %7B%0A%0A    private final OutputStream os;%0A    // Buffer size has not been tuned.%0A    private final byte%5B%5D buffer;%0A    private int numBytes;%0A%0A    /**%0A     * @param os need not be buffered as this class buffers%0A     */%0A    public AsciiWriter(final OutputStream os, int bufferSize) %7B%0A        this.os = os;%0A        numBytes = 0;%0A        this.buffer = new byte%5BbufferSize%5D;%0A    %7D%0A%0A    /**%0A     * flushes and closes underlying OutputStream.%0A     */%0A    @Override%0A    public void close() throws IOException %7B%0A        flush();%0A        os.close();%0A    %7D%0A%0A    /**%0A     * flushes underlying OutputStream%0A     */%0A    @Override%0A    public void flush() throws IOException %7B%0A        os.write(buffer, 0, numBytes);%0A        numBytes = 0;%0A        os.flush();%0A    %7D%0A%0A    /**%0A     * All other Writer methods vector through this, so this is the only one that must be overridden.%0A     */%0A    @Override%0A    public void write(final char%5B%5D chars, int offset, int length) throws IOException %7B%0A        while (length %3E 0) %7B%0A            final int charsToConvert = Math.min(length, buffer.length - numBytes);%0A            StringUtil.charsToBytes(chars, offset, charsToConvert, buffer, numBytes);%0A            numBytes += charsToConvert;%0A            offset += charsToConvert;%0A            length -= charsToConvert;%0A            if (numBytes == buffer.length) %7B%0A                os.write(buffer, 0, numBytes);%0A                numBytes = 0;%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A%0A

add ascii writer adapted from htsjdk