zoukankan      html  css  js  c++  java
  • 记一次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文件夹的权限不够的原因导致的

  • 相关阅读:
    For-Each循环
    test
    网络学习一
    Struts2的interceptor
    Struts2的action解读
    js 读取<select>标签选项 索引
    java项目打jar包
    图解sendRedirect和forward的区别
    导入外部项目无法识别为Web项目无法部署到tomcat
    项目乱码的分析与解决
  • 原文地址:https://www.cnblogs.com/shuixingshushuren/p/13683974.html
Copyright © 2011-2022 走看看