@Override public void write(FileChannel fileChannel) throws IOException { byteBuffer().position(0); byteBuffer().putShort(magic); byteBuffer().putLong(this.firstRecordId); byteBuffer().flip(); fileChannel.position(0); fileChannel.write(byteBuffer()); fileChannel.force(true); } }
@Override public void write(FileChannel fileChannel) throws IOException { byteBuffer().position(0); byteBuffer().putShort(magic); byteBuffer().putLong(this.firstRecordId); byteBuffer().flip(); fileChannel.position(0); fileChannel.write(byteBuffer()); fileChannel.force(true); } }
@Override public void read(FileChannel fileChannel) throws IOException { if (fileChannel.size() == 0) { return; } fileChannel.position(0); fileChannel.read(byteBuffer()); byteBuffer().position(0); short readMagic = byteBuffer().getShort(); if (readMagic != magic) { throw new IOException("Invalid file type magic number 0x" + Integer.toHexString(readMagic & 0xFFFF)); } this.firstRecordId = byteBuffer().getLong(); }
@Override public void read(FileChannel fileChannel) throws IOException { if (fileChannel.size() == 0) { return; } fileChannel.position(0); fileChannel.read(byteBuffer()); byteBuffer().position(0); short readMagic = byteBuffer().getShort(); if (readMagic != magic) { throw new IOException("Invalid file type magic number 0x" + Integer.toHexString(readMagic & 0xFFFF)); } this.firstRecordId = byteBuffer().getLong(); }
@Override public void write(FileChannel fileChannel) throws IOException { byteBuffer().position(0); byteBuffer().putShort(magic); byteBuffer().putLong(this.firstRecordId); byteBuffer().flip(); fileChannel.position(0); fileChannel.write(byteBuffer()); fileChannel.force(true); } }
@Override public void read(FileChannel fileChannel) throws IOException { if (fileChannel.size() == 0) { return; } fileChannel.position(0); fileChannel.read(byteBuffer()); byteBuffer().position(0); short readMagic = byteBuffer().getShort(); if (readMagic != magic) { throw new IOException("Invalid file type magic number 0x" + Integer.toHexString(readMagic & 0xFFFF)); } this.firstRecordId = byteBuffer().getLong(); }