Here you can find the source of saveToFile(String data, File file)
public static void saveToFile(String data, File file) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static void saveToFile(String data, File file) throws IOException { FileOutputStream fos = null; try {//from w w w. ja va 2 s. c o m fos = new FileOutputStream(file); fos.write(data.getBytes()); } finally { if (fos != null) fos.close(); } } public static void saveToFile(byte[] data, File file) throws IOException { FileOutputStream fos = null; try { fos = new FileOutputStream(file); fos.write(data); } finally { if (fos != null) fos.close(); } } }