If you plan to use only the JDK, you may need to wrap your BufferedWriter with PrintWriter , as in
PrintWriter printWriter=new PrintWriter(bufferedWriter); printWriter.println(yourString);
The printWriter script has a nice println method.
Or, if you are free to use external libraries, try FileUtils writeStringToFile
source share