List of utility methods to do Text File Save
File | writeFile(File path, String fileName, String fileContent) write File if (fileContent != null && fileContent.trim().length() > 0) { path.mkdirs(); File out = new File(path, fileName); BufferedWriter writer = new BufferedWriter(new FileWriter(out)); writer.write(fileContent); writer.close(); return out; return null; |
void | writeFile(File target, String content) write File PrintWriter p = null; try { p = new PrintWriter(new FileWriter(target)); p.write(content); } catch (Exception e) { throw new RuntimeException("Problems writing text to file: " + target); } finally { close(p); ... |
void | writeFile(final byte[] content, final String path) write File FileOutputStream stream = new FileOutputStream(path); try { stream.write(content); } finally { stream.close(); |
void | writeFile(final File destination, final List Write the strings to the file, one per line. final BufferedWriter bw = new BufferedWriter(new FileWriter(destination)); try { for (String line : contents) { bw.write(line); bw.newLine(); bw.flush(); } finally { ... |
void | writeFile(final File f, final String content) Write the content to the file. final FileOutputStream o = new FileOutputStream(f); o.write(content.getBytes()); o.close(); |
void | writeFile(final File outputFile, final String data, final String encoding) Writes the given String data to the given output file, encoded using the given encoding. final FileOutputStream outStream = new FileOutputStream(outputFile); OutputStreamWriter writer = null; try { writer = new OutputStreamWriter(outStream, encoding); writer.write(data); } finally { if (writer != null) { writer.close(); ... |
void | writeFile(final String aText, final File aFile, final String aEncoding) For tests only. Writer writer = null; try { aFile.getParentFile().mkdirs(); writer = new OutputStreamWriter(new FileOutputStream(aFile), aEncoding); writer.write(aText); } finally { close(writer); |
void | writeFile(final String file, final String text) Method declaration try { final FileWriter write = new FileWriter(file); write.write(text.toCharArray()); write.close(); } catch (IOException e) { e.printStackTrace(); |
void | writeFile(final String name, final String s) Writes to the file with the given name writeFile(name, s, false); |
void | writeFile(final String nameFile, final List Imprime a lista em uma arquivo. try { Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(nameFile), "utf-8")); for (String msg : listMsg) { writer.write(msg + "\n"); writer.close(); } catch (IOException e) { System.err.println("Erro ao escrever resultado no arquivo de saida. " + e); ... |