Java examples for File Path IO:ByteBuffer
Writing and Appending a ByteBuffer to a File
import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; public class Main { public void m() { // Write bbuf to filename ByteBuffer bbuf = ByteBuffer.wrap("test".getBytes()); File file = new File("filename"); boolean append = false; try {/* ww w . j av a2 s .c o m*/ // Create a writable file channel FileChannel wChannel = new FileOutputStream(file, append).getChannel(); wChannel.write(bbuf); wChannel.close(); } catch (IOException e) { } } }