Java File Write nio writeFile(String folder, String aFileName, String aItem)

Here you can find the source of writeFile(String folder, String aFileName, String aItem)

Description

write File

License

Open Source License

Declaration

public static void writeFile(String folder, String aFileName, String aItem) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedWriter;

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

public class Main {
    private final static Charset ENCODING = StandardCharsets.UTF_8;

    public static void writeFile(String folder, String aFileName, String aItem) throws IOException {
        Path path = Paths.get(folder, aFileName);
        try (BufferedWriter writer = Files.newBufferedWriter(path, ENCODING)) {
            writer.write(aItem);//from ww  w.j ava  2s  .c om
            writer.newLine();
        }
    }
}

Related

  1. writeFile(List content, String targetFile)
  2. writeFile(OutputStream file, List data)
  3. writeFile(String filename, byte file[])
  4. writeFile(String fileName, String content)
  5. writeFile(String fileName, String content)
  6. writeFile(String name, String content)