However, FileWriter is a pretty inadequate and ancient class and there are better options.
Personally, I suggest you use PrintWriter, as in this example:
try {
.. PrintWriter out = new PrintWriter("/Users/yourusername/filenam... "UTF-8");
.. out.println ("The quick brown fox jumps over the lazy dog");
.. out.close();
}
catch (Exception e) {
.. System.out.println ("Cannot open output file");
.. System.out.println (e);
}
Once you've opened the output stream, you can use print(), println () and printf () on it, with any reasonable set of parameters, so it's very simple to use. The only hassle is you've got to put these statements in a try { } with a suitable catch ().
Maybe the flie was chinese.
I am a beginner learning Java, and am working through a program that is supposed to output a txt file with certain lines of English text. I'm using the FileWriter and BufferedWriter objects, and the write() and newLine() objects. I'm running this on a mac, would that have anything to do with it?