package javaapplication1;
import java.io.*;
public class Example {
public static void main(String[] args) throws IOException {
try (Writer writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("d:\\data.txt"), "utf-8")))
{
writer.write("line 1" + System.lineSeparator() + "line 2");
}
catch(IOException ex)
{
System.out.println(ex.toString());
System.exit(1);
}
}
}
/*
run:
*/