@Override protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception { return new RamFileRandomAccessContent(this, mode); }
@Override public long skip(final long n) throws IOException { seek(getFilePointer() + n); return n; }
@Override public int read() throws IOException { try { return readByte(); } catch (final EOFException e) { return -1; } }
@Override public char readChar() throws IOException { final int ch1 = this.readUnsignedByte(); final int ch2 = this.readUnsignedByte(); return (char) ((ch1 << 8) + (ch2 << 0)); }
@Override public int readUnsignedShort() throws IOException { this.readFully(buffer2); return toUnsignedShort(buffer2); }
@Override public void readFully(final byte[] b, final int off, final int len) throws IOException { if (len < 0) { throw new IndexOutOfBoundsException("Length is lower than 0"); } if (len > this.getLeftBytes()) { throw new IndexOutOfBoundsException( "Read length (" + len + ") is higher than buffer left bytes (" + this.getLeftBytes() + ") "); } System.arraycopy(buf, filePointer, b, off, len); filePointer += len; }
@Override public void readFully(final byte[] b) throws IOException { this.readFully(b, 0, b.length); }
@Override public int skipBytes(final int n) throws IOException { if (n < 0) { throw new IndexOutOfBoundsException("The skip number can't be negative"); } final long newPos = filePointer + n; if (newPos > buf.length) { throw new IndexOutOfBoundsException("Tyring to skip too much bytes"); } seek(newPos); return n; }
@Override public float readFloat() throws IOException { return Float.intBitsToFloat(this.readInt()); }
@Override public double readDouble() throws IOException { return Double.longBitsToDouble(this.readLong()); }
@Override public boolean readBoolean() throws IOException { return (this.readUnsignedByte() != 0); }
@Override public int readUnsignedShort() throws IOException { this.readFully(buffer2); return toUnsignedShort(buffer2); }
@Override public void readFully(final byte[] b, final int off, final int len) throws IOException { if (len < 0) { throw new IndexOutOfBoundsException("Length is lower than 0"); } if (len > this.getLeftBytes()) { throw new IndexOutOfBoundsException( "Read length (" + len + ") is higher than buffer left bytes (" + this.getLeftBytes() + ") "); } System.arraycopy(buf, filePointer, b, off, len); filePointer += len; }
@Override public void readFully(final byte[] b) throws IOException { this.readFully(b, 0, b.length); }