对数据和信息的存储,使用I/O流保存到文件夹 public static void save(){try {ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream(new File("G:\\jxnd\\com\\hah.txt")));oos.writeObject(TeacherManager.list);oos.clo
public static void save(){
try {
ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream(new File("G:\\jxnd\\com\\hah.txt")));
oos.writeObject(TeacherManager.list);
oos.close();
} catch (FileNotFoundException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
public static void load(){
try {
ObjectInputStream ois=new ObjectInputStream(new FileInputStream(new File("G:\\jxnd\\com\\hah.txt")));
TeacherManager.list=(List
) ois.readObject();
} catch (FileNotFoundException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
public static void fsave(){
try {
ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream(new File("G:\\jxnd\\com\\jie.txt")));
oos.writeObject(StudentManager.flist);
oos.close();
} catch (FileNotFoundException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
public static void fload(){
try {
ObjectInputStream ois=new ObjectInputStream(new FileInputStream(new File("G:\\jxnd\\com\\jie.txt")));
StudentManager.flist=(List
) ois.readObject(); } catch (FileNotFoundException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } catch (IOException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } }
