Here you can find the source of stringToFile(String filename, String stringToWrite)
Parameter | Description |
---|---|
filename | path to file |
stringToWrite | string to save |
public static void stringToFile(String filename, String stringToWrite)
//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 { /**//from w w w.j a v a2 s . c o m * 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) { } } }