List of utility methods to do UTF File Write
PrintWriter | asPrintWriterUTF8(OutputStream out) Create a print writer that uses UTF-8 encoding return new PrintWriter(asUTF8(out)); |
BufferedWriter | getBufferedUTF8Writer(File file) Creates a BufferedWriter for UTF-8-encoded files return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), Charset.forName("UTF-8"))); |
Writer | getUTF8FileAppendWriter(String filename) get UTF File Append Writer return new BufferedWriter( new OutputStreamWriter(new FileOutputStream(getFile(filename), true), StandardCharsets.UTF_8)); |
Writer | getUTF8FileWriter(File f) get UTF File Writer return getUTF8FileWriter(f.getPath());
|
Writer | getUTF8Writer(OutputStream os) Create a new file writer that uses UTF-8. return new OutputStreamWriter(os, StandardCharsets.UTF_8); |
Writer | getUTF8Writer(String file) get UTF Writer return new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)); |
Writer | utf8Writer(File file) Creates a writer whose character encoding is set to "UTF-8". return utf8Writer(file, false);
|
Writer | utf8Writer(final File f) Creates a Writer that writes to the given file, converting chars to bytes using the UTF-8 charset. return new OutputStreamWriter(new FileOutputStream(f), UTF8); |
void | writeFile(byte[] data, String outfile) write File FileOutputStream fout = null; FileChannel fc = null; try { fout = new FileOutputStream(outfile); fc = fout.getChannel(); fc.transferFrom(Channels.newChannel(new ByteArrayInputStream(data)), 0, data.length); } catch (Exception e) { e.printStackTrace(); ... |
boolean | writeFile(String fileName, ArrayList write the contents of given data (list of lines) under given fileName in given outputFolder try { Path outputFile = Paths.get(outputFolder + File.separator + fileName); createFoldersForPath(outputFile.toAbsolutePath().toString()); Files.write(outputFile, data, Charset.forName("UTF-8")); return true; } catch (IOException e) { e.printStackTrace(); return false; ... |