免费网站软件大全,西安seo阳建,2019流行做什么网站网站,网站快照描述目录 1.问题描述2.主要原因2.1修改后代码2.2修改前代码 总结参考 1.问题描述
预览excel文件时无法找到对应的html文件 2.主要原因 异常原因#xff1a;代码获取的是系统的tmp文件#xff0c;但是linux环境环境中心tmp目录是没有权限的#xff0c;所以不能获取系统的根目录…
目录 1.问题描述2.主要原因2.1修改后代码2.2修改前代码 总结参考 1.问题描述
预览excel文件时无法找到对应的html文件 2.主要原因 异常原因代码获取的是系统的tmp文件但是linux环境环境中心tmp目录是没有权限的所以不能获取系统的根目录下的tmp需要自己创建个临时目录
2.1修改后代码
在项目路径下创建临时文件
String userTemRoot /excel/media/;String userTemPath fileHost userTemRoot;File temFolder new File(userTemPath);if (null temFolder || !temFolder.exists()) {temFolder.mkdirs();}String excelPath userTemPath UUIDGenerate.getUnid() . ext;File file new File(excelPath);InputStream in InputStreamUtil.byteToInputStream(buffer);InputStreamUtil.inputStreamToFile(in, file);content ExcelToHtml.excelWriteToHtml(excelPath);jsonObject.put(data, content);return jsonObject;2.2修改前代码 String temRoot System.getProperty(JAVA_IO_TMPDIR);String temPath temRoot XLS;File temFolder new File(temPath);if (null temFolder || !temFolder.exists()) {temFolder.mkdirs();}String excelPath temPath File.separator UUIDGenerate.getUnid() . ext;File file new File(excelPath);InputStream in InputStreamUtil.byteToInputStream(buffer);InputStreamUtil.inputStreamToFile(in, file);content ExcelToHtml.excelWriteToHtml(excelPath);jsonObject.put(DATA, content);return jsonObject;总结
一些文件的读写在window下的执行时没有阻碍的但是到了linux环境下需要考虑一些权限问题,面向的大部分用户都是没有完整权限的普通用户没有权限读取根目录下的临时文件。
参考
Linux中提示No such file or directory解决方法
给个三连吧 谢谢谢谢谢谢了