记一次FileOutputStream出现FileNotFoundException(stale file handle)的问题


 

排查了代码理论上不会出现FileNotFoundException问题

  String staffCode) throws Exception {
        String path = "D:\\sss\\"+staffCode+"_"+(new SimpleDateFormat("yyMMddHHmmss").format(new Date()))+"\\";
        // String path = "/data/file/" + staffCode + "_" + (new SimpleDateFormat("yyMMddHHmmss").format(new Date())) + "/";
        log.error("获取的路径:" + path);
        String fileName = "上传" + System.currentTimeMillis();
        String filePath = path + fileName;
        fileNewPath.append(path);
        File file = new File(filePath);
        if (!file.exists()) {
            file.mkdirs();
        }
        FileOutputStream fileOutputStream = new FileOutputStream(filePath + "/上传" + System.currentTimeMillis() + ExcelTypeEnum.XLSX.getValue());
        fileOutputStream.write(baos.toByteArray());
        fileOutputStream.close();

        genImages(list3, filePath);
        log.error("filePath" + filePath);
        return setZip(filePath, path, fileName);

 

后来发现三台服务器中只有一台在报错,检查服务器找到原因是/data/file文件夹的权限不够的原因导致的

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM