Java tutorial
//package com.java2s; // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of import java.io.BufferedWriter; import java.io.FileWriter; public class Main { /** * Saves passed string to file * * @param filename path to file * @param stringToWrite string to save */ public static void stringToFile(String filename, String stringToWrite) { try { BufferedWriter writer = new BufferedWriter(new FileWriter(filename)); writer.write(stringToWrite); writer.flush(); writer.close(); } catch (Exception ignored) { } } }