标签:tput print sys 遍历 file int rac let nts
//创建文件 private static void createFile(File file){ try { if(!file.exists()){ if(file.getParentFile() != null){ file.getParentFile().mkdirs(); } file.createNewFile(); } FileOutputStream output = new FileOutputStream(file); output.write(file.getPath().getBytes()); output.flush(); output.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } //遍历文件 private static void listFiles(File file){ File[] files = file.listFiles(); if(files != null){ for (File file2 : files) { listFiles(file2); } }else{ System.out.println(file.getPath()); } } //删除文件 private static void deleteFile(File file){ if(file.isDirectory()){ File[] files = file.listFiles(); for (File file2 : files) { deleteFile(file2); } file.delete(); }else{ file.delete(); } }
标签:tput print sys 遍历 file int rac let nts
原文地址:http://www.cnblogs.com/wenhui92/p/7308224.html