List of usage examples for java.io File isDirectory
public boolean isDirectory()
From source file:Main.java
public static void visitAllFiles(File dir) { if (dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { visitAllFiles(new File(dir, children[i])); }//from w ww.j av a 2s .co m } else { System.out.println(dir); } }
From source file:Main.java
public static void visitAllDirs(File dir) { if (dir.isDirectory()) { System.out.println(dir);/*from www .ja va 2s. com*/ String[] children = dir.list(); for (int i = 0; i < children.length; i++) { visitAllDirs(new File(dir, children[i])); } } }
From source file:Main.java
public static boolean deleteDir(File dir) { if (dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { boolean success = deleteDir(new File(dir, children[i])); if (!success) { return false; }//w ww . ja v a 2 s . c o m } } return dir.delete(); }
From source file:DirList.java
private static void listDirectories(File dir, String indent) { File[] dirs = dir.listFiles(); for (File f : dirs) { if (f.isDirectory()) { System.out.println(indent + f.getName()); listDirectories(f, indent + " "); }/*from ww w .j a va 2s. com*/ } }
From source file:Main.java
public static void visitAllDirsAndFiles(File dir) { System.out.println(dir);//from w ww. ja v a 2 s . c o m if (dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { visitAllDirsAndFiles(new File(dir, children[i])); } } }
From source file:DirectoryTree.java
public static void tree(String filename) { File file = new File(filename); if (!file.isDirectory()) { System.out.println(filename); return;//from w w w .j av a 2 s .c om } String files[] = file.list(); for (int i = 0; i < files.length; i++) { tree(filename + File.separator + files[i]); } }
From source file:Main.java
public static void delete(File file) { if (file.isDirectory()) { File[] childs = file.listFiles(); for (File file2 : childs) delete(file2);// w ww. j av a2s. c o m } file.delete(); }
From source file:Main.java
public static void deleteRecyle(File file) { if (file.isDirectory()) { for (File childFile : file.listFiles()) { deleteRecyle(childFile);//from ww w . ja va 2 s. c o m } } file.delete(); }
From source file:Main.java
private static void deleteFileAndAnyContents(File file) { if (file.isDirectory()) for (File child : file.listFiles()) { deleteFileAndAnyContents(child); }//from w ww . ja va2 s . c om file.delete(); }
From source file:Main.java
public static void rm(File f) { if (f.isDirectory()) { for (File ff : f.listFiles()) { rm(ff);//from w w w . j a v a 2 s. c om } f.delete(); } else if (f.isFile()) { f.delete(); } }