@@ -0,0 +1,2007 @@
+package de.jangobrick.scratchlib.writer;%0A%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.IOException;%0Aimport java.nio.ByteBuffer;%0Aimport java.nio.charset.StandardCharsets;%0A%0A%0A/**%0A * Extension of %7B@code ByteArrayOutputStream%7D for writing more types of data%0A * than just bytes.%0A */%0Apublic class ScratchOutputStream extends ByteArrayOutputStream%0A%7B%0A    /**%0A     * Converts the string to US-ASCII bytes and writes them out.%0A     * %0A     * @param s The string to write.%0A     * @throws IOException%0A     */%0A    public void writeString(String s) throws IOException%0A    %7B%0A        write(s.getBytes(StandardCharsets.US_ASCII));%0A    %7D%0A%0A    /**%0A     * Converts the int to 4 bytes (big-endian) and writes them out.%0A     * %0A     * @param i The int to write.%0A     * @throws IOException%0A     */%0A    public void write32bitUnsignedInt(int i) throws IOException%0A    %7B%0A        write(ByteBuffer.allocate(4).putInt(i).array());%0A    %7D%0A%0A    /**%0A     * Converts the int to 3 bytes (big-endian) and writes them out. The fourth%0A     * byte is discarded in the process, effectively reducing the number range.%0A     * %0A     * @param i The int to write.%0A     * @throws IOException%0A     */%0A    public void write24bitUnsignedInt(int i) throws IOException%0A    %7B%0A        write(ByteBuffer.allocate(4).putInt(i).array(), 1, 3);%0A    %7D%0A%0A    /**%0A     * Converts the int to 2 bytes (big-endian) and writes them out. The third%0A     * and fourth bytes are discarded in the process, and so the number is%0A     * equivalent to a short.%0A     * %0A     * @param i The int to write.%0A     * @throws IOException%0A     */%0A    public void write16bitUnsignedInt(int i) throws IOException%0A    %7B%0A        write(ByteBuffer.allocate(4).putInt(i).array(), 2, 2);%0A    %7D%0A%0A    /**%0A     * Converts the double to 8 bytes (big-endian) and writes them out.%0A     * %0A     * @param d The double to write.%0A     * @throws IOException%0A     */%0A    public void write64bitDecimal(double d) throws IOException%0A    %7B%0A        write(ByteBuffer.allocate(8).putDouble(d).array());%0A    %7D%0A%7D%0A

Add ScratchOutputStream