List of utility methods to do Text File Write nio
void | writeString(DataOutput dOut, String value) Writes out value to dOut. if (value == null) { dOut.writeUTF(value); return; byte[] data = value.getBytes(StandardCharsets.UTF_8.name()); if (data.length > CONVERSION_TRESHOLD) { dOut.writeUTF(DATA_VERSION); dOut.writeInt(data.length); ... |
void | writeString(File file, String content) write String writeBytes(file, content.getBytes(StandardCharsets.UTF_8), 1); |
void | writeString(final File file, final String str) Writes a string to a file. writeString(new FileOutputStream(file), str);
|
void | writeString(OutputStream buffer, String s) write String if (s == null || s.isEmpty()) { writeCompactInt(buffer, 0); return; s += '\0'; boolean def = defaultEncoder.canEncode(s); byte[] bytes = s.getBytes(def ? defaultCharset : utf16leCharset); writeCompactInt(buffer, def ? bytes.length : -bytes.length / 2); ... |
void | writeStringToFile(File file, String content, String value) write String To File Files.write(file.toPath(), Collections.singletonList(new String(content.getBytes(value), value)),
Charset.forName(value), StandardOpenOption.CREATE);
|
void | writeStringToFile(File file, String string) write String To File Files.write(file.toPath(), string.getBytes(TEXT_CHARSET)); |
void | writeStringToFile(File file, String text) write the given String to a the given file Files.write(Paths.get(file.toURI()), text.getBytes()); |
void | writeStringToFile(final File file, final String content) write String To File if (content == null) { throw new UnsupportedOperationException("Cannot write null to file. Consider deleting it instead"); try (OutputStream fos = openOutputStream(file)) { fos.write(content.getBytes(Charset.forName("UTF-8"))); |
void | writeStringToFile(String s, File f) Writes a string into a file, using UTF-8 encoding BufferedWriter w = null; try { w = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f), Charset.forName("UTF-8"))); w.append(s); } finally { if (w != null) { w.close(); |
void | writeTextFile(final File file, final String text) write Text File final OutputStream stream = new FileOutputStream(file); final BufferedOutputStream output = new BufferedOutputStream(stream); final OutputStreamWriter writer = new OutputStreamWriter(output, UTF_8); writer.write(text); writer.flush(); writer.close(); |