class BinaryReader {

    public String readString(int length) throws IOException {
        StringBuilder result = new StringBuilder(length - 1);
        boolean foundNull = false;
        int exclusiveLastIndex = position + length;
        for (int i = position; i < exclusiveLastIndex; i++) {
            byte b = bytes[i];
            if (b == 0) {
                foundNull = true;
                break;
            }
            result.append((char) b);
        }
        if (!foundNull) {
            throw new IOException("Expected null terminated string");
        }
        position += length;
        return result.toString();
    }

    public  BinaryReader(BinaryReader binaryReader, int position);
    public  BinaryReader(InputStream inputStream, int size);
    public  BinaryReader(byte[] bytes);

}