Java examples for java.io:FileWriter
Write a string to a file using FileWriter
//package com.java2s; import java.io.FileWriter; import java.io.IOException; public class Main { /**/* w w w . ja v a 2 s . co m*/ * Write a string to a file * * @param str * string to write * * @param path * file path */ public static void writeTofile(final String str, final String path) { FileWriter fw = null; try { fw = new FileWriter(path); fw.write(str); } catch (final IOException e) { throw new RuntimeException(e); } finally { if (fw != null) { try { fw.close(); } catch (final IOException e) { } } } } }