gpt4 book ai didi

java - 为什么简单的 FileInputStream 行返回异常?

转载 作者:行者123 更新时间:2023-12-01 12:37:54 24 4
gpt4 key购买 nike

按钮操作;

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
try {
// TODO add your handling code here:
deneme();
} catch (IOException ex) {
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
}
}

文件读取无效;

public void deneme() throws FileNotFoundException, IOException{
try {
FileInputStream file2 = FileInputStream (new File("D:\\Ornek.xls"));
HSSFWorkbook workbook;
workbook = new HSSFWorkbook(file2);
HSSFSheet sheet = workbook.getSheetAt(0);
HSSFRow row1 = sheet.getRow(0);
HSSFCell cellA1 = row1.getCell((short) 0);
String a1Val = cellA1.getStringCellValue();
HSSFCell cellB1 = row1.getCell((short) 1);
String b1Val = cellB1.getStringCellValue();
HSSFCell cellC1 = row1.getCell((short) 2);
String c1Val = cellC1.getStringCellValue();;

System.out.println("A1: " + a1Val);
System.out.println("B1: " + b1Val);
System.out.println("C1: " + c1Val);
}
catch (IOException ex) {
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null,ex);
}


}

调试时出现以下异常;

Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not supported yet.

FileInputStream 行引发异常。我错过了什么吗?

谢谢。

-- 已解决 --

抱歉,首先问了一个愚蠢的问题:)

FileInputStream file2 = new FileInputStream (new File("D:\\Ornek.xls"));

new 关键字开头缺失。感谢@dkatzel

最佳答案

我认为您缺少 new 关键字。

试试这个:

FileInputStream file2 = new FileInputStream (new File("D:\\Ornek.xls"));

但是,这应该是编译错误而不是运行时错误。

关于java - 为什么简单的 FileInputStream 行返回异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25406377/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com