How to assign a String from a text file into integer array for Java? I had saved the integer array into a text file, but now how can I retrieve all the integer array from the text file without any modification? I want the integer array retrieved same as before it stored into the text file. Below is part of my code:
BufferedWriter f1 = new BufferedWriter(new InputStreamReader(new FileInputStream("Input.txt")));
int a[ ] = yes(test, test.length); //go to yes method,return value to array
for(int i = 0; i < a.length; i++)
{
f1.write(a[i]);
}
f1.close( );
BufferedReader f2 = new BufferedReader(new InputStreamReader(new FileInputStream("Input.txt")));
String src;
while((src = f2.readLine( )) != null)
{
String[ ] s = src;
int a[ ] = Integer.parseInt(s);//same with before it saved
... ...
}
(incompatible types found)
How to reserve the originality of the integer array(a[ ]) after saved and retrieved from the text file? Thanks!