我们一直运行这个错误。目标是将数组中的数据读入输出文件。谢谢您的帮助!
public static void save(Salesperson[] array)
{
PrintStream outfile = null;
try
{
outfile = new PrintStream(new FileOutputStream("data.txt"));
}
catch(FileNotFoundException e)
{
JOptionPane.showMessageDialog(null,"The file could not be created.");
}
System.setOut(new PrintStream(new FileOutputStream("output.txt")));
for(int k = 0; k < array.length; k++)
{
System.out.println(array[k]);
}
outfile.close();
System.out.println("Saved.");
}