问题:如果我运行的代码在另一个系统中转换为.JAR文件,则无法访问EXCEL工作表路径
InputStream Readexcel = null;
Readexcel = getClass().getClassLoader().getResourceAsStream("/Config.properties");
FileInputStream is = new FileInputStream("C:\\Software\\Automation\\book1.xls");
HSSFWorkbook workbook = new HSSFWorkbook(is);
HSSFSheet sheet = workbook.getSheet("Sheet1");
答案 0 :(得分:0)
您还需要在jar中加入Config.properties
。
如果您正在使用eclipse生成jar,那么您需要在导出jar时检查资源文件夹中的复选框(如果您的Config.properties
在资源文件夹中),以便它包含属性文件jar文件并可用。