List of utility methods to do Write String to File
void | writeFile(String filePath, String content, boolean append) write File File file = new File(filePath); if (createFile(filePath)) { BufferedWriter bufferedWriter = null; try { FileWriter fileWriter = new FileWriter(file, append); bufferedWriter = new BufferedWriter(fileWriter); bufferedWriter.write(content); bufferedWriter.flush(); ... |
void | writeFile(String filePath, String contents) write File writeFile(filePath, contents, true); |
boolean | writeFile(String filePath, String fileContent) write File FileWriter fw = null; try { fw = new FileWriter(filePath, true); PrintWriter pw = new PrintWriter(fw); pw.print(fileContent); pw.close(); fw.close(); return true; ... |
int | writeFile(String filePath, String fileData, boolean isAppend) writes file data try { File file = new File(filePath); if (!file.exists()) { file.mkdirs(); file.createNewFile(); BufferedWriter out = new BufferedWriter(new FileWriter(filePath, isAppend)); out.write(fileData); ... |
void | writeFile(String filePath, String fileName, String[] args) write File File f = new File(filePath); if (!f.exists()) { f.mkdirs(); FileWriter fw = new FileWriter(filePath + fileName); PrintWriter out = new PrintWriter(fw); for (int i = 0; i < args.length; i++) { out.write(args[i]); ... |
boolean | writeFile(String filePath, String templetContent, String charsetName) write File boolean isSucc = false; try { if (filePath != null && !filePath.equals("")) { File file = new File(filePath.substring(0, filePath.lastIndexOf(File.separator))); if (file.exists() == false) { file.mkdirs(); FileOutputStream fout = new FileOutputStream(filePath); OutputStreamWriter out = new OutputStreamWriter(new BufferedOutputStream(fout), charsetName); out.write(templetContent); out.close(); fout.close(); isSucc = true; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); return isSucc; |
void | writeFile(String filePath, String text) write File BufferedWriter bw = null; try { bw = new BufferedWriter(new FileWriter(filePath, true)); bw.write(text); bw.flush(); } catch (IOException e) { e.printStackTrace(); } finally { ... |