Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to write an interger value in a text file using java

807588May 6 2009 — edited May 6 2009
Hai 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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 3 2009
Added on May 6 2009
3 comments
107 views