I am wondering how you would output from a program to a text file for data handling.
Any help would be much appreciated :)
Printable View
I am wondering how you would output from a program to a text file for data handling.
Any help would be much appreciated :)
Moved From The CodeBank
Again, I've never used J#, but this is how you could do it in Java.
import
ThenCode:import java.io.*;
Code://create the output stream
FileOutputStream out = new FileOutputStream("outFile.txt");
//create the print stream to write to the output stream
PrintStream p = new PrintStream(out);
//write to the printstream
p.println ("Write a line. You can also use print if you don't want to force a new line");
//and finally close
p.close();
In J#, it's pretty much the same way you'd do in Java (as outlined above), but instead you use the System.IO.StreamWriter object, and you'd use the StreamWriter equivalent to println. If you have experimented with any .NET programming languages, the latter should be obvious once you start using the StreamWriter object.