linux 文件注意事项

来源:互联网 发布:大数据广告投放优势 编辑:程序博客网 时间:2024/06/14 21:58

1.分隔符/和windows的\不一样,指定路径时会出问题

if(!System.getProperty("os.name").toLowerCase().startsWith("win")){
path = PropertiesTool.getSystemPram("ssrPath") + "/"+ ssr.getADDRESS();
}

2.新建文件时注意父目录是否存在

 file.setWritable(true,false);
       if (!file.getParentFile().exists()) {  
           file.getParentFile().mkdirs();
             
       }  
       if(!file.exists()){
        file.createNewFile();
       }

0 0