Here you can find the source of saveFile(String content, String path)
public static File saveFile(String content, String path)
//package com.java2s; //License from project: Open Source License import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static File saveFile(String content, String path) { BufferedOutputStream stream = null; File file = null;//from w w w. j av a2 s. co m try { file = new File(path); if (!file.exists()) file.createNewFile(); FileOutputStream fstream = new FileOutputStream(file); stream = new BufferedOutputStream(fstream); byte[] b = content.getBytes("UTF-8"); stream.write(b); } catch (Exception e) { e.printStackTrace(); } finally { if (stream != null) { try { stream.close(); } catch (IOException e1) { e1.printStackTrace(); } } } return file; } }