package com.jscape.util.io.primitive;

import com.jscape.util.IOTools;
import com.jscape.util.io.DataCodec;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * @author Alex Usun
 */
public class ByteCodec
        implements DataCodec<Byte> {

    public static void writeValue(byte value, OutputStream out)
            throws IOException {
        out.write(value);
    }

    public static byte readValue(InputStream in)
            throws IOException {
        return (byte) IOTools.read(in);
    }

    public void write(Byte data, OutputStream out)
            throws IOException {
        writeValue(data, out);
    }

    public Byte read(InputStream in)
            throws IOException {
        return readValue(in);
    }
}
