記一次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