Here you can find the source of dumpBytesToFile(byte[] bytes, String outputFile)
public static void dumpBytesToFile(byte[] bytes, String outputFile)
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; public class Main { public static void dumpBytesToFile(byte[] bytes, String outputFile) { try {//from w w w .j a v a 2 s .co m BufferedWriter bw = new BufferedWriter(new FileWriter(outputFile)); for (int i = 0; i < bytes.length; ++i) { bw.write(getByteAsAscii(bytes[i])); if ((i + 1) % 16 == 0) { bw.write("\n"); } } bw.close(); } catch (IOException e) { e.printStackTrace(); } } public static char getByteAsAscii(byte b) { char output = '.'; if (b > 31) { output = (char) b; } return output; } }