Java examples for java.nio:ByteBuffer File
Dump the given ByteBuffer 's bytes to a file.
//package com.java2s; import java.io.*; import java.nio.ByteBuffer; public class Main { /**// w w w .j a v a2 s.c o m * Dump the given {@link ByteBuffer}'s bytes to a file. * * @param buf The {@link ByteBuffer} to dump. * @param fileName The name of the file to dump to. */ public static void dumpToFile(ByteBuffer buf, String fileName) { try { final FileOutputStream fos = new FileOutputStream(fileName); fos.write(buf.array()); fos.close(); } catch (Exception e) { e.printStackTrace(); System.exit(-1); } } }