Code example for ByteBuffer

Methods: capacity, getInt, limit, position

0
                                  + " in: " + filename);
        } 
    } 
 
    private String readString() {
        final int stringBytes = mBuffer.getInt();
        mBuffer.limit(stringBytes + mBuffer.position());
        final String result = CHARSET.decode(mBuffer).toString();
        mBuffer.limit(mBuffer.capacity());
        return result;
    } 
 
    public LockingContext readContext(int id) {
        mBuffer.position(id);
        return new LockingContext(readString(), 
                                  readString(), 
                                  readString()); 
    } 
 
    public Lock readLock(int id) {
        mBuffer.position(id);