List of utility methods to do Text File Write by Charset
boolean | write(String toWrite, File file, Charset charset) write FileLock lock = null; FileChannel fileChannel = null; try { if (!file.exists() && !file.createNewFile()) { return false; fileChannel = FileChannel.open(file.toPath(), StandardOpenOption.READ, StandardOpenOption.WRITE); ByteBuffer buffer = ByteBuffer.wrap(toWrite.getBytes(charset)); ... |
void | writeAll(Path path, String data, Charset cs) write All try (OutputStream os = Files.newOutputStream(path, StandardOpenOption.CREATE,
StandardOpenOption.TRUNCATE_EXISTING)) {
os.write(data.getBytes(ENCODING_UTF8));
|
void | writeAll(String data, OutputStream outputStream, Charset charset) Write string to byte stream writeAll(data, outputStream, charset.name()); |
void | writeContent(String content, String charset, File file) write Content if (file.isDirectory()) { throw new IOException("Cannot write content to directory"); if (file.exists()) { file.createNewFile(); FileOutputStream fos = new FileOutputStream(file); fos.write(content.getBytes(charset)); ... |
boolean | writeFile(File file, String content, Charset charset) write File try { BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset)); bw.write(content); bw.flush(); bw.close(); return true; } catch (IOException e) { return false; ... |
void | writeFile(String content, File file, Charset encoding) write File try (Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), encoding))) { out.write(content); |
Boolean | writeFile(String path, String content, Charset charset) write File Writer writer = null; try { writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path), charset)); if (content != null) { writer.write(content); } catch (IOException e) { return false; ... |
void | writeFile(String path, String content, Charset encoding) write text to file Files.write(Paths.get(path), content.getBytes(encoding), StandardOpenOption.CREATE); |
void | writeFile(String path, String output, Charset encoding) write File Files.write(Paths.get(path), output.getBytes(encoding)); |
OutputStreamWriter | writer(OutputStream out, String charset) writer OutputStreamWriter result; if (charset == null) { result = writer(out); } else { result = writer(out, Charset.forName(charset)); return result; |