1 private void createPath(String path){ 2 String os = System.getProperty("os.name"); 3 String tmpPath = path; 4 //兼容 linux 系統 5 if(os.toLowerCase().startsWith("win")){ 6 tmpPath = path.replaceAll("/", "\\\\"); 7 } 8 //判斷路徑是否存在 9 File filePath = new File(tmpPath); 10 if(!filePath.exists()){ 11 //不存在,創建目錄 12 filePath.mkdirs(); 13 } 14 }