Java Path File Content writeLines(Path base, String file, String[] content)

Here you can find the source of writeLines(Path base, String file, String[] content)

Description

write Lines

License

Apache License

Declaration

public static Path writeLines(Path base, String file, String[] content) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;
import java.nio.charset.Charset;
import java.nio.file.*;

public class Main {
    private static Charset CHARSET = Charset.forName("UTF-8");

    public static Path writeLines(Path base, String file, String[] content) {
        Path out = base.resolve(file);
        try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(out, CHARSET))) {
            for (String line : content) {
                writer.println(line);/*from  www.  j a  v a2 s.  c o  m*/
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return out;
    }
}

Related

  1. writeFile(String path, String content)
  2. writeFile(String path, String content)
  3. writeFile(String path, String contents)
  4. writeFileContents(Path to, byte[] contents)
  5. writeJsonToFile(Path jsonPath, String jsonContent)
  6. writeString(String content, Path path)
  7. writeStringToFile(String content, Path targetPath)
  8. writeToBinaryFile(String filePath, byte[] binaryContent)
  9. writeToFile(Path absolutePath, byte[] content)