<<< FileChannel class | Index | Example: FileChannel and ByteBuffer classes >>> |
Class java.nio.ByteBuffer helper object represents a sequence of raw bytes
wrap() method wraps a byte array into a ByteBuffer object:
String str = "XYZ"; byte[] data = str.getBytes(); ByteBuffer out = ByteBuffer.wrap( data );
FileChannel object can then write the ByteBuffer into the file:
fc.write( out );
<<< FileChannel class | Index | Example: FileChannel and ByteBuffer classes >>> |