I would like to write file in JAVA
FileUtils.writeLines(new File(baseFolder.getAbsolutePath() + File.separatorChar + filename), data);
Apache FileUtils.writeLines
UTF-8
ANSI
LF
CR LF
Linux
Windows
Invoke the appropriate overload of writeLines
, with the parameters in the right order:
public static void writeLines(File file, String encoding, Collection<?> lines, String lineEnding) throws IOException
e.g.
FileUtils.writeLines(
new File(baseFolder.getAbsolutePath(), filename),
"Cp1252",
data,
"\r\n");
Note that Windows ANSI isn actually called Cp1252
in Java, according to this answer.
You are passing the encoding as the last parameter to this overload, which is actually the line ending parameter.
public static void writeLines(File file, Collection<?> lines, String lineEnding) throws IOException