
how to write integer data to a file in java using random access file object or file writer or data outputstream i have already tried the write and writeInt methods....plz help

Java write to File:
import java.io.*;
import java.util.*;
class AcceptNumbers{
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
BufferedWriter bw=new BufferedWriter(new FileWriter(new File("C:/numbers.txt"),true));
for(int i=1;i<=10;i++){
System.out.print("Enter Number "+i+": ");
int num=input.nextInt();
bw.write(Integer.toString(num));
bw.newLine();
}
bw.close();
System.out.println("Numbers are store into the file");
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.