Java Path File Write nio saveHeaders(Path path, ArrayList headers)

Here you can find the source of saveHeaders(Path path, ArrayList headers)

Description

save Headers

License

Open Source License

Declaration

synchronized public static void saveHeaders(Path path, ArrayList<String> headers) 

Method Source Code


//package com.java2s;
// Use of this software is governed by the GPLv3 license

import java.io.BufferedWriter;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;

import java.util.ArrayList;

public class Main {
    synchronized public static void saveHeaders(Path path, ArrayList<String> headers) {
        try (BufferedWriter writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) {
            for (String line : headers) {
                writer.write(line);//  w w  w.  j  a v  a  2s.  c o  m
                writer.newLine();
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

Related

  1. overwriteFile(final String newFilePath, final String oldFilePath)
  2. removeMatchingLines( final Map d1LineMap, final Path tableDir, final String table, final BufferedWriter errors)
  3. robustCheckWriteable(Path logFile)
  4. save(Object o, String path)
  5. saveFile(String path, String text)
  6. saveProperties(Path filePath, Properties prop)
  7. saveTo(String path, InputStream in)
  8. saveToFile(String path, byte[] text)
  9. setPosixPermissions(String path, boolean ownerRead, boolean ownerWrite, boolean ownerExecute, boolean groupRead, boolean groupWrite, boolean groupExecute, boolean othersRead, boolean othersWrite, boolean othersExecute)