My problem is that I want to create a System-type object only the first time I start the program, the next time I want to read the saved System file.
public static void main(String[] args) {
Sistema sistema;
try {
sistema = new Sistema();
FileOutputStream file = new FileOutputStream("archivo_sistema.txt");
BufferedOutputStream bf = new BufferedOutputStream(file);
ObjectOutputStream obj = new ObjectOutputStream(bf);
obj.writeObject(sistema);
obj.flush();
obj.close();
FileInputStream recuperar_file = new FileInputStream("archivo_sistema.txt");
BufferedInputStream bi = new BufferedInputStream(recuperar_file);
ObjectInputStream obs = new ObjectInputStream(bi);
sistema = (Sistema)(obs.readObject());
} catch (ClassNotFoundException | IOException e) {
e.printStackTrace();
}
JFrameMenu vMenu = new JFrameMenu(sistema);
vMenu.setVisible(true);
}
}