Hey there,
I'm new to java and I need to write a string that i generated in my code to an output file. I'm currently writing the string to the standard output like so :
System.out.println("K_"+Receiver+",t"+msgnum+"(R("
+Receiver+",t"+msgnum+"("+out1+")))");
All the types e.g. 'Receiver' or 'out1' are of type string. Could anyone show me how to open a file for writing and then write this information to the file? Is there some sort of file writer equivalent for system.out.println()? Thanks very much
You can read about File streams of java :
Anywayz I give you some code ... You have to write exceptions yourself:
String s ="this is the string you want to write to the file.";
File name = new File("sani.txt");
FileWriter fw = new FileWriter(name);
fw.write(s);
fw.close;
nanosani
Unauthenticated Liar
1,830 posts since Jul 2004
Reputation Points: 45
Solved Threads: 56