Java ByteBuffer Dump dumpToFile(ByteBuffer buf, String fileName)

Here you can find the source of dumpToFile(ByteBuffer buf, String fileName)

Description

Dump the given ByteBuffer 's bytes to a file.

License

Open Source License

Parameter

Parameter Description
buf The ByteBuffer to dump.
fileName The name of the file to dump to.

Declaration

public static void dumpToFile(ByteBuffer buf, String fileName) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;
import java.nio.ByteBuffer;

public class Main {
    /**//ww  w . j  a va2 s  .  co  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);
        }
    }
}

Related

  1. dumpBytes(ByteBuffer bbuf)
  2. dumpBytes(ByteBuffer byteBuffer)
  3. dumpBytes(PrintStream ps, ByteBuffer buf)
  4. dumpHexString(ByteBuffer bb)
  5. dumpNextNBytes(ByteBuffer buffer, int n)
  6. hexDump(ByteBuffer buffer)
  7. hexDump(PrintStream ps, ByteBuffer bb)
  8. printByteDump(StringBuilder strBuilder, ByteBuffer data, int offset, int length, int columnNum)
  9. setDecreasedBuffer(ByteBuffer memoryDumpReader, long baseAddressValue, int innerPointerOffset, long memoryDumpStartingOffset)