package com.conveyal.r5.analyst;

import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * Class to output ints. An order of magnitude faster than Guava LittleEndianDataOutputStream.
 */
public class LittleEndianIntOutputStream extends FilterOutputStream {
    public LittleEndianIntOutputStream(OutputStream out) {
        super(out);
    }

    public void writeInt (int value) throws IOException {
        byte[] bytes = new byte[]{
                (byte) (value & 0xff),
                (byte) (value >> 8 & 0xff),
                (byte) (value >> 16 & 0xff),
                (byte) (value >> 24 & 0xff)
        };

        out.write(bytes);
    }
}

@@ -118,16 +118,49 @@
 tStream;
+%0Aimport java.nio.charset.Charset;
 %0A%0A/**%0A *
@@ -720,11 +720,247 @@
 );%0A    %7D
+%0A%0A    /** Write an ASCII string as bytes, generally used as a header */%0A    public void writeAscii(String accessgr) throws IOException %7B%0A        byte%5B%5D bytes = accessgr.getBytes(Charset.forName(%22ASCII%22));%0A        out.write(bytes);%0A    %7D
 %0A%7D%0A

add writeChars method to LittleEndianIntOutputStream.