I am trying to create and write to a java file using print writer.
I looked at How do I create a file and write to it in Java?
I am unable to write to the file. The file is created but with no text
Can someone please tell me what I missed?
Thanks
static void createFile() throws FileNotFoundException{
String filename = "nothign.txt";
FileOutputStream connection1;
connection1 = new FileOutputStream( filename );
PrintWriter printnothing = null;
printnothing = new PrintWriter(connection1);
printnothing.printf("/nnewline writesomething/n exo");
printnothing.println("trying to write something");
}// createFile Method