Here you can find the source of saveToFile(String buf, String fileName)
public static void saveToFile(String buf, String fileName)
//package com.java2s; //License from project: Apache License import java.io.FileOutputStream; import java.io.PrintWriter; public class Main { public static void saveToFile(String buf, String fileName) { try (PrintWriter out = new PrintWriter(fileName)) { out.println(buf);/* w w w . j a v a 2s .co m*/ } catch (Exception e) { throw new RuntimeException("Failed to write content to file " + fileName, e); } } public static void saveToFile(byte[] buf, String fileName) { try (FileOutputStream fos = new FileOutputStream(fileName)) { fos.write(buf); } catch (Exception e) { throw new RuntimeException("Failed to write content to file " + fileName, e); } } }