Java Utililty Methods Text File Write nio

List of utility methods to do Text File Write nio

Description

The list of methods to do Text File Write nio are organized into topic(s).

Method

voidwrite(File file, List lines, StandardOpenOption... options)
write
try {
    Files.write(file.toPath(), lines, CHARSET, options);
} catch (IOException ex) {
    throw new RuntimeException(ex);
voidwrite(File file, String content)
write
try {
    Files.write(file.toPath(), content.getBytes());
} catch (IOException ex) {
    throw new RuntimeException(ex);
voidwrite(File file, String data, boolean append)
write
Set<OpenOption> options = new HashSet<OpenOption>();
options.add(StandardOpenOption.CREATE);
options.add(StandardOpenOption.WRITE);
if (append) {
    options.add(StandardOpenOption.APPEND);
} else {
    options.add(StandardOpenOption.TRUNCATE_EXISTING);
write(file, data, options.toArray(new OpenOption[options.size()]));
voidwrite(final Map dataBase, final File currentFile)
write
OutputStream currentStream = new FileOutputStream(currentFile);
BufferedOutputStream bufferStream = new BufferedOutputStream(currentStream, BUF_SIZE);
DataOutputStream dataStream = new DataOutputStream(bufferStream);
long biasing = 0;
for (String key : dataBase.keySet()) {
    biasing += key.getBytes(StandardCharsets.UTF_8).length + POS_STEP;
List<String> values = new ArrayList<String>(dataBase.keySet().size());
...
voidwrite(final Object o, final String filename)
write to gzip file.
try (final BufferedWriter bw = setUpWriter(filename)) {
    bw.write(MAPPER.writeValueAsString(o));
    bw.close();
voidwrite(final OutputStream outputStream, final String string)
write
write(outputStream, string.getBytes(DEFAULT_CHARSET));
voidwrite(final StringBuffer data, final Writer output)
Writes chars from a StringBuffer to a Writer.
if (data != null) {
    output.write(data.toString());
voidwrite(OutputStream stream, String string)
write
Writer out = new OutputStreamWriter(stream, Charset.forName("utf8"));
out.write(string);
out.flush();
voidwrite(String content, String file)
write
try (BufferedWriter writer = new BufferedWriter(
        new OutputStreamWriter(new FileOutputStream(file), Charset.defaultCharset()))) {
    writer.write(content);
Filewrite(String location, String content)
write
File file = new File(location);
file.getParentFile().mkdirs();
Files.write(content, file, Charset.defaultCharset());
return file;