I am trying to write numbers to a text file. i have tried most of the classes in java.io but whenever i write a number to a file it comes up as jibberish. anyone know what class to use?
Printable View
I am trying to write numbers to a text file. i have tried most of the classes in java.io but whenever i write a number to a file it comes up as jibberish. anyone know what class to use?
BufferedReader with a FileReader is good. http://java.sun.com/j2se/1.3/docs/ap...redReader.html
I would do this :
that should do itCode:import java.io.*;
public class WriteIntToFile
{
public static void main(String[] args)
{
PrintWriter pw = new PrintWriter(new FileWriter("c:\\test.txt",true), true); //FileWriter:true = append, PrintWriter:true = autoflush
for (int x=0; x<10; x++)
{
pw.println(x);
}
pw.close();
}
}
:)