Code example for FileChannel

Methods: write

0
		FileChannel channel = fos.getChannel();
		byte[] message = "SomeMessage".getBytes();
		ByteBuffer buffer = ByteBuffer.allocate(1024);
		buffer.put(message);
		buffer.flip();
		channel.write(buffer);
	} 
 
	public static void read() throws FileNotFoundException, IOException { 
		FileInputStream fis = new FileInputStream(READ_FILE);
		FileChannel channel = fis.getChannel();
		ByteBuffer buffer = ByteBuffer.allocateDirect(1024);
		System.out.println(channel.read(buffer));
	} 
} 
Contextual code suggestions in your IDE  Get Codota for Java