java将InputStream转换为FileInputStream不适用于Apache POI
我试图从我的res/raw文件夹中访问excel文件,我知道你只能使用InputStream来实现这一点;然而,ApachePOI中的XSSFWorkbook命令只接受FileInputStreams而不接受InputStreams:有什么方法可以做到这一点吗?我尝试使用以下代码,但出现了以下错误:java.lang.NullPointerException: Attempt to invoke virtual method 'java.net.URI java.net.URL.toURI()' on a null object reference
以下是我尝试使用的代码:
URL ins = this.getClass().getResource("ncaa.xlsx");
FileInputStream file = new FileInputStream(new File(ins.toURI()));
XSSFWorkbook workbook = new XSSFWorkbook(file);
共 (0) 个答案