How to write an interger value in a text file using java
807588May 6 2009 — edited May 6 2009Hai toall,
Can any one please tell me how to an interger value in a textfile. I could write a string into a file. But i am unable to write an integer value.
i wrote like this in my program.
public void writeToFile(int number) {
int no;
try {
String f = "RecordCount.txt";
FileOutputStream fop = new FileOutputStream(f);
no=number;
fop.write(no);
fop.flush();
fop.close();
System.out.println("The data has been written");
} catch (Exception e) {
e.printStackTrace();
}
}
it didnt show any error. But interger value coudnt write into a file.
Any one please help me out from this.
Thanks in advance.