'How can I read a binary file and display it in JTable?

How can I read a binary file and display it in a JTable?

From the code that saves the file like this in Java:

private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {
    int returnVal = jFileChooser.showSaveDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        try {
            File file = jFileChooser.getSelectedFile();
            this.jTextField.setText(file.getAbsolutePath());
            FileOutputStream fileOut = new FileOutputStream(file);
            ObjectOutputStream out = new ObjectOutputStream(fileOut);
            
            for(int i=0; i < tblSinhVien.getRowCount(); i++) {
                for(int j=0; j<tblSinhVien.getColumnCount(); j++) {
                    out.writeObject(tblSinhVien.getValueAt(i, j));
                }
            }
            out.close();
            fileOut.close();
            this.jTextField.setText("Đã lưu");
        } catch(IOException e) {
            Logger.getLogger(Student_JFrame.class.getName()).log(Level.SEVERE, null, e);
        }
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source