package com.quantxt.io.file;

import java.io.BufferedReader;
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;
import java.util.List;

/**
 * Utility class for text file read/write operations
 *
 * @author dejani
 *
 */
public class FileUtil {

    public final static Charset ENCODING = StandardCharsets.UTF_8;
    public final static String LINE_SEPARATOR = System.getProperty("line.separator");

    /**
     * Read all lines for a given file and return them as List.
     * It is used default encoding {@link StandardCharsets#UTF_8}.
     *
     * @param fileName represents file location
     *
     * @return the lines from the file as a List of String
     *
     * @throws IOException
     */
    public static List<String> readLines(String fileName)
            throws IOException {
        return readLines(fileName, ENCODING);
    }

    /**
     * Read all lines for a given file and return them as List with provided encoding.
     *
     * @param fileName represents file location
     * @param encoding represents Charset used for decoding
     *
     * @return the lines from the file as a List of String
     *
     * @throws IOException
     */
    public static List<String> readLines(String fileName, Charset encoding)
            throws IOException {
        Path path = Paths.get(fileName);
        return Files.readAllLines(path, ENCODING);
    }

    /**
     * Read content of file and return as text.
     * It is used default encoding {@link StandardCharsets#UTF_8}.
     *
     * @param fileName represents file location
     *
     * @return text from the file as String
     *
     * @throws IOException
     */
    public static String readText(String fileName) throws IOException {
        return readText(fileName, ENCODING);
    }

    /**
     * Read content of file and return as text using given encoding.
     *
     * @param fileName represents file location
     * @param encoding represents Charset used for decoding
     *
     * @return text from the file as String
     *
     * @throws IOException
     */
    public static String readText(String fileName, Charset encoding)
            throws IOException {
        Path path = Paths.get(fileName);
        final StringBuilder builder = new StringBuilder();
        try (BufferedReader reader = Files.newBufferedReader(path, encoding)) {
            String line = null;
            while ((line = reader.readLine()) != null) {
                builder.append(line);
                builder.append(LINE_SEPARATOR);
            }
        }
        return builder.length() == 0 ? null : builder.toString();
    }

    /**
     * Write given list of lines into file.
     * It is used default encoding {@link StandardCharsets#UTF_8}.
     *
     * @param fileName represents file location
     * @param lines to be written in file
     *
     * @throws IOException
     */
    public static void writeText(String fileName, List<String> lines)
            throws IOException {
        writeText(fileName, lines, ENCODING);
    }

    /**
     * Write given list of lines into file.
     * It is used default encoding {@link StandardCharsets#UTF_8}.
     *
     * @param fileName represents file location
     * @param lines to be written in file
     * @param encoding represents Charset use for encoding
     *
     * @throws IOException
     */
    public static void writeText(String fileName, List<String> lines,
            Charset encoding)
            throws IOException {
        Path path = Paths.get(fileName);
        try (BufferedWriter writer = Files.newBufferedWriter(path, encoding)) {
            for (String line : lines) {
                writer.write(line);
                writer.newLine();
            }
        }
    }

}

@@ -3043,36 +3043,37 @@
 tatic void write
-Text
+Lines
 (String fileName
@@ -3140,20 +3140,21 @@
    write
-Text
+Lines
 (fileNam
@@ -3237,75 +3237,8 @@
 le.%0A
-     * It is used default encoding %7B@link StandardCharsets#UTF_8%7D.%0A
     
@@ -3459,20 +3459,21 @@
 id write
-Text
+Lines
 (String 
@@ -3827,10 +3827,930 @@
 %0A    %7D%0A%0A
+    /**%0A     * Write given text into file.%0A     * It is used default encoding %7B@link StandardCharsets#UTF_8%7D.%0A     *%0A     * @param fileName represents file location%0A     * @param text to be written in file%0A     *%0A     * @throws IOException%0A     */%0A    public static void writeText(String fileName, String text)%0A            throws IOException %7B%0A        writeText(fileName, text, ENCODING);%0A    %7D%0A%0A    /**%0A     * Write given text into file.%0A     *%0A     * @param fileName represents file location%0A     * @param text to be written in file%0A     * @param encoding represents Charset use for encoding%0A     *%0A     * @throws IOException%0A     */%0A    public static void writeText(String fileName, String text, Charset encoding)%0A            throws IOException %7B%0A        Path path = Paths.get(fileName);%0A        try (BufferedWriter writer = Files.newBufferedWriter(path, encoding)) %7B%0A            writer.write(text);%0A        %7D%0A    %7D%0A%0A
 %7D%0A

Add write simple text