package com.jscape.inet.ssh.protocol.v2.marshaling.primitive;

import com.jscape.util.IOTools;

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

/**
 * @author Alex Usun
 */
public class ByteArrayCodec {

    public static byte[] readValue(int length, InputStream in)
            throws IOException {
        byte[] data = new byte[length];
        IOTools.read(data, in);

        return data;
    }

    public static void writeValue(byte[] value, int offset, int length, OutputStream out)
            throws IOException {
        out.write(value, offset, length);
    }

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

    private ByteArrayCodec() {
    }
}
