PDA

Click to See Complete Forum and Search --> : outputting to a .txt file from J#


vbtom
Mar 9th, 2010, 08:37 AM
I am wondering how you would output from a program to a text file for data handling.

Any help would be much appreciated :)

Hack
Mar 9th, 2010, 09:01 AM
Moved From The CodeBank

kfcSmitty
Mar 9th, 2010, 12:54 PM
Again, I've never used J#, but this is how you could do it in Java.

import

import java.io.*;


Then


//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();

kregg
Mar 13th, 2010, 06:31 AM
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.