List of usage examples for java.io File isDirectory
public boolean isDirectory()
From source file:Main.java
private static void clearDir(String projectDir) { File file = new File(projectDir); File[] files = file.listFiles(); if (files == null || files.length == 0) { return;//from w w w .j a va2s . c om } for (File f : files) { if (f.isDirectory()) { clearDir(f.getAbsolutePath()); } else { f.delete(); } } }
From source file:Main.java
static public void deleteAllSDContent() { String dir_path = Environment.getExternalStorageDirectory().getPath() + "/swift"; File f = new File(dir_path); if (f.isDirectory()) { String files[] = f.list(); for (int i = 0; i < files.length; i++) { new File(dir_path, files[i]).delete(); }/* ww w. j a va2s. com*/ } }
From source file:Main.java
public static void deleteFile(String path) { File file = new File(path); if (file.isDirectory()) {//delete dir File[] childFile = file.listFiles(); for (File tempFile : childFile) { tempFile.delete();/* w w w. j a v a 2 s . co m*/ } file.delete(); } else {//delete file file.delete(); } }
From source file:Main.java
public static void deleteRecursive(File fileOrDirectory) { if (fileOrDirectory.isDirectory()) for (File child : fileOrDirectory.listFiles()) deleteRecursive(child);/* w ww. ja v a2 s . co m*/ fileOrDirectory.delete(); }
From source file:Main.java
public static boolean deleteDir(File dir) { if (dir != null && dir.isDirectory()) { String[] children = dir.list(); for (String aChildren : children) { boolean success = deleteDir(new File(dir, aChildren)); if (!success) { return false; }/*from w w w .ja v a 2 s . c om*/ } } assert dir != null; return dir.delete(); }
From source file:Main.java
public static void File_iterateFiles(String dir) { File f = new File(dir); File[] files = f.listFiles(); if (null != files) { for (File ff : files) { if (ff.isDirectory()) { File_iterateFiles(ff.getPath()); } else { //TODO }//from ww w . ja va 2 s . co m } } }
From source file:Main.java
public static List<String> getFile(String path, Integer count, String fileEnd, List<String> result) { File f = new File(path); File[] files = f.listFiles(); for (File s : files) { if (s.isDirectory()) { getFile(s.getAbsolutePath(), count, fileEnd, result); } else {//from w ww . ja v a 2 s. c om if (s.getName().toLowerCase().endsWith(fileEnd.toLowerCase())) { result.add(s.getAbsolutePath()); } } } return result; }
From source file:Main.java
public static void removeDirectory(File dir) { if (dir.isDirectory()) { final File[] files = dir.listFiles(); if (files != null) { for (final File file : files) { removeDirectory(file);/*from w ww . j a va 2 s . c o m*/ } } dir.delete(); } else { dir.delete(); } }
From source file:Main.java
public static boolean deleteDir(File dir) { if (dir != null && dir.isDirectory()) { String[] children = dir.list(); for (String aChildren : children) { boolean success = deleteDir(new File(dir, aChildren)); if (!success) { return false; }/*ww w . j av a 2 s .c om*/ } } // The directory is now empty so delete it return dir != null && dir.delete(); }
From source file:Main.java
private static void dirChecker(String rootDir, String dir) { File f = new File(rootDir + "/" + dir); if (!f.isDirectory()) { f.mkdirs();/* www .jav a 2s . c o m*/ } }