Here you can find the source of saveFile(String fileName, String data)
public static void saveFile(String fileName, String data)
//package com.java2s; //License from project: Open Source License import java.io.FileNotFoundException; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; public class Main { public static void saveFile(String fileName, String data) { PrintWriter writer = null; try {//w ww . j a v a 2s.co m writer = new PrintWriter(fileName, "UTF-8"); writer.print(data); } catch (FileNotFoundException | UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (writer != null) writer.close(); } } }