【问题标题】:java.io.FileNotFoundException: C:\Engines\Data.xlsx (The system cannot find the file specified)java.io.FileNotFoundException: C:\Engines\Data.xlsx(系统找不到指定的文件)
【发布时间】:2019-02-22 14:41:01
【问题描述】:

我的系统中有一个名为 data 的现有文件,但它仍然显示 The system cannot find the file specified.

我正在尝试使用读取 xlsx 文件的所有方法创建现有类的对象。

我的代码:

public class sampletestjava {

public static void main(String[] args) {

    System.out.println("learning maven");
    XLS_Reader xls = new XLS_Reader("C:\\Engines\\Data.xlsx");

错误

(java.io.FileNotFoundException): C:\Engines\Data.xlsx (系统找不到指定的文件)

【问题讨论】:

  • C:\\Engines\\Data.xlsx 可能需要为C:\\\\Engines\\Data.xlsx,因为您需要双重转义驱动器路径

标签: java file filenotfoundexception


【解决方案1】:

尽量保持绝对路径字符串如下:

  D:/eip_eclipse_workspace/codeTesting/properties/keystore_file/keystore

就像你的情况一样:

  XLS_Reader xls = new XLS_Reader("C:/Engines/Data.xlsx");

【讨论】:

    【解决方案2】:
    File myFile = new File("C://Engines/Data.xlsx");
                FileInputStream fis = new FileInputStream(myFile);
    
    OR
    
    FileInputStream fis = new FileInputStream(new File("C://Engines/Data.xlsx"));
    

    有没有像 XLS_Reader 这样的类或接口? 即使我也在学习,但据我所知不是。 如果是,请更新我

    也可以使用 java.io 概念 为了使用 Office 文件,您需要了解“Apache POI”。 寻找https://www.javatpoint.com/apache-poi-tutorial

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 2013-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-11
      相关资源
      最近更新 更多