Here you can find the source of WriteFile(String sFileName, String content)
Parameter | Description |
---|---|
sFileName | file name |
content | the content that need to write to file |
public static boolean WriteFile(String sFileName, String content)
//package com.java2s; //License from project: Open Source License import java.io.FileWriter; import java.io.IOException; public class Main { /**/*from w ww .j a va2s . co m*/ * Write content to file * * @param sFileName * file name * @param content * the content that need to write to file * @return true if write success or false if write fail */ public static boolean WriteFile(String sFileName, String content) { FileWriter fw = null; try { fw = new FileWriter(sFileName, true); fw.write(content); fw.close(); } catch (IOException e) { e.printStackTrace(); // if abnormal then return false return false; } finally { if (fw != null) { try { fw.close(); } catch (IOException e1) { } } } // if finish writing then return true return true; } }