I have this fragment of code where the if question if it was not written in all the JTextField and if it does it creates the file (the file saves an arraylist) .. now, my doubt comes from how I do to show the data of the file in a JTable that is in another class.
if (nombre.getText().equals("") != (documento.getText().equals("")) != (apellido.getText()).equals("")) {
JOptionPane.showMessageDialog(this, "POR FAVOR LLENAR TODAS LAS CASILLAS ", "ERROR", JOptionPane.OK_OPTION);
} else {
lista.add(new Datos.Hotel(documento.getText(), nombre.getText(), apellido.getText(), habitacion.getText()));
try {
FileOutputStream fos = new FileOutputStream("L:\final\PruebaHotel.txt");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(lista);
JOptionPane.showMessageDialog(null, "Datos guardados");
oos.close();// cierra el archivo
} catch (FileNotFoundException e) {
JOptionPane.showMessageDialog(null, "El archivo no existe " + e);
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, "Los datos de salida no son correctos " + ex);
}
}