Here you can find the source of writeStringToFile(File p_out, String p_str)
Parameter | Description |
---|---|
p_out | The output file |
p_str | The string to write |
public static boolean writeStringToFile(File p_out, String p_str)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; public class Main { /**// ww w . ja va 2s . c o m * Writes a string to a file * @param p_out The output file * @param p_str The string to write * @return The success status */ public static boolean writeStringToFile(File p_out, String p_str) { try { OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(p_out)); osw.write(p_str + System.lineSeparator()); osw.flush(); osw.close(); } catch (FileNotFoundException e) { return false; } catch (IOException e) { return false; } return true; } }