linux 文件注意事项

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();
       }

猜你喜欢

转载自blog.csdn.net/tian2342/article/details/51330881