如何将文本文件中的字符串分配给 Java 的整数数组?我已将整数数组保存到文本文件中,但现在如何在不进行任何修改的情况下从文本文件中检索所有整数数组?我希望检索的整数数组与将其存储到文本文件之前相同。以下是我的部分代码:
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
... ...
}
(发现不兼容的类型)
整数数组(a[ ]) 保存并从文本文件中检索后如何保留其原创性?谢谢!