Here you can find the source of writeFile(String filePath, String fileData, boolean isAppend)
Parameter | Description |
---|---|
filePath | a parameter |
fileData | a parameter |
isAppend | a parameter |
public static int writeFile(String filePath, String fileData, boolean isAppend)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.BufferedWriter; import java.io.FileWriter; public class Main { public static String LAST_ERROR = ""; /**/* w ww.j a v a 2 s . c o m*/ * writes file data * * @param filePath * @param fileData * @param isAppend * @return */ public static int writeFile(String filePath, String fileData, boolean isAppend) { try { // create file File file = new File(filePath); if (!file.exists()) { file.mkdirs(); file.createNewFile(); } // write to file BufferedWriter out = new BufferedWriter(new FileWriter(filePath, isAppend)); out.write(fileData); out.close(); // done return 1; } catch (Exception e) { LAST_ERROR = e.getMessage(); e.printStackTrace(); return -1; } } }