Code example for FileChannel

Methods: read

0
    } 
 
    private void validateHeader(FileChannel channel,
                                String filename) throws IOException {
        final ByteBuffer buffer = ByteBuffer.allocate(8 + 4 + 4);
        channel.read(buffer);
        buffer.flip();
        if (MAGIC_COOKIE != buffer.getLong()) {
            throw new IOException("Invalid file contents in: " + filename);
        } 
        final int majorVersion = buffer.getInt();
        final int minorVersion = buffer.getInt();
        if (majorVersion != MAJOR_VERSION) {
            throw new IOException("Incompatible version: "
                                  + majorVersion + "." + minorVersion
                                  + " in: " + filename);
        } 
    } 
 
    private static void parseLockEvent(ByteBuffer lockEventBuffer,
                                       LockEventListenerIfc eventReceiver)