List of utility methods to do Text File Save
boolean | writeFile(String filePath, List Writes the given lines to the file at the given path. File file = new File(filePath); if (!file.exists()) { try { file.createNewFile(); } catch (Exception failure) { return false; try (PrintWriter writer = new PrintWriter(file.getAbsolutePath(), "UTF-8")) { for (String line : lines) { writer.println(line); writer.flush(); writer.close(); } catch (Exception failure) { return false; return true; |
void | writefile(String path, String content) writefile FileWriter out = new FileWriter(path);
out.write(content);
out.close();
|
void | writefile(String path, String content) writefile File f = new File(path); if (f.exists()) f.delete(); FileWriter out = new FileWriter(f); out.write(content); out.close(); |
boolean | writeFile(String path, String content) write File boolean successed = false; OutputStream fos = null; Writer osw = null; try { File file = new File(path); if (!file.exists()) { file.getParentFile().mkdirs(); file.createNewFile(); ... |
String | writeFile(String path, String content) write File byte[] matter = content.getBytes("GBK"); return writeFile(path, matter, false); |
void | writefile(String path, String content, boolean append) writefile BufferedWriter bw; File targetFile; try { targetFile = new File(path); if (targetFile.exists() == false) { targetFile.createNewFile(); FileWriter fw = new FileWriter(targetFile, append); ... |
void | writeFile(String path, String contents) write File PrintWriter out = null; try { out = new PrintWriter(new BufferedWriter(new FileWriter(path))); out.print(contents); out.flush(); } finally { if (out != null) { out.close(); ... |
void | writeFile(String path, String data) write File File file = new File(path.substring(0, path.lastIndexOf("/"))); file.mkdirs(); FileWriter fileWriter = new FileWriter(path); BufferedWriter out_j = new BufferedWriter(fileWriter); out_j.write(data); out_j.close(); |
void | writeFile(String path, String fileName, String content) Saves the String's content into the file. String s = new String(); String s1 = new String(); String fullPath = path + File.separator + fileName; String dirPath = path; try { File file = new File(fullPath); File dirFile = new File(dirPath); if (!(dirFile.isDirectory())) { ... |
String | writeFile(String path, String fileName, String content, String charset) write File mkDir(path); String filePath = path + File.separator + fileName; File file = new File(filePath); if (file.exists()) { file.delete(); file.createNewFile(); FileOutputStream fops = new FileOutputStream(file); ... |