遇到麻烦。
我有一个我输出到文件的ArrayList,我希望能够打开这个文件并在jTextField中显示内容
private void btnSubmitActionPerformed(java.awt.event.ActionEvent evt) {
computer= new Computer();
computer.setComputerType(cbType.getSelectedItem().toString() +"\n");
computer.setWeight(txtWeight.getText() +"\n");
computer.setBatteryLife(txtBattery.getText() +"\n");
computer.setScreenSize(txtScreenSize.getText() +"\n");
computer.setRamSize(txtRAM.getText() +"\n");
computer.setOS(cbOS.getSelectedItem().toString() +"\n");
computer.setManufacturerName(txtManufacturer.getText() +"\n");
computer.setProcessorModel(txtCPU.getText() +"\n");
computer.setCpuCoreType(txtCPUCore.getText() +"\n");
//Store computer in ArrayList
myComputerList.add(computer);
System.out.print("Size of array " + myComputerList.size() + "\n");
System.out.print("\n");
}
private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {
try {
ObjectOutputStream outputStream = new ObjectOutputStream(
new FileOutputStream("ArrayFile.bin"));
outputStream.writeObject(myComputerList);
outputStream.close();
System.out.println("Array output file" + "\n");
}
catch(IOException err)
{
System.out.println("Problem with file output");
}
System.out.println("Computer written to the file computers.bin");
}