Here you can find the source of save2File(String fileName, String content)
public static int save2File(String fileName, String content)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileWriter; import java.io.IOException; public class Main { public static int save2File(String fileName, String content) { File file = new File(fileName); try {/*from w w w .j a v a 2 s. co m*/ // if the file is not exist, create it! if (file.exists() == false) { file.createNewFile(); } // the second parameter is 'true' means add contents at the end of // the file FileWriter writer = new FileWriter(fileName); writer.write(content); writer.close(); return 1; } catch (IOException e) { e.printStackTrace(); return 0; } } }