java.io.IOException: 使用 awt 关闭流

java.io.IOException: Stream closed with awt

我正在尝试构建代码以导入 Excel 文件,我一直在关注视频,但最终我的代码不起作用(我仔细检查)我收到此错误

我相信,我有合适的库,也许视频可能有点过时并且代码不再起作用。


 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        
        
        DefaultTableModel ImportDataFromExcelModel = (DefaultTableModel) jTable1.getModel();
        
        FileInputStream excelFIS = null;
        BufferedInputStream excelBIS = null;
        XSSFWorkbook excelImportWorkBook = null;

        String currentDirectoryPath = "";
        JFileChooser excelFileChooserImport = new JFileChooser(currentDirectoryPath);

        int excelChooser = excelFileChooserImport.showOpenDialog(null);

        if (excelChooser == JFileChooser.APPROVE_OPTION) {
            try {
                File excelFile = excelFileChooserImport.getSelectedFile();
                excelFIS = new FileInputStream(excelFile);
                excelBIS = new BufferedInputStream(excelBIS);
                excelImportWorkBook = new XSSFWorkbook(excelBIS);
                XSSFSheet excelSheet = excelImportWorkBook.getSheetAt(0);

                for(int num = 0 ; num < excelSheet.getLastRowNum() ; num++){
                XSSFRow excelRow = excelSheet.getRow(num);
                
                XSSFCell cell = excelRow.getCell(1); 
                
                System.out.println(cell);
                
                ImportDataFromExcelModel.addRow(new Object [] {cell});
                        
                }
                
            } catch (FileNotFoundException ex) {
             ex.printStackTrace();
            } catch (IOException ex) {
             ex.printStackTrace();
            }

        }

first half of the error message

second half of the error message

enter image description here

检查第 14 行的代码