记一次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文件夹的权限不够的原因导致的

 

posted @ 2020-09-17 11:08  水星说书人  阅读(1396)  评论(0编辑  收藏  举报