List of usage examples for java.io File listFiles
public File[] listFiles()
From source file:Main.java
public static boolean deleteFolder(File folder) { if (!folder.exists()) { return true; }/*from w w w . j a va 2 s . co m*/ File[] subFiles = folder.listFiles(); if (subFiles != null) { for (File f : subFiles) { if (f.isFile()) { if (!f.delete()) { return false; } } else { if (!deleteFolder(f)) { return false; } } } } return folder.delete(); }
From source file:Main.java
private static void deleteCacheFile(File file) { if (file.isFile()) { file.delete();/* ww w. j av a2s . c o m*/ } else { File[] files = file.listFiles(); for (File f : files) { deleteCacheFile(f); } } }
From source file:com.gargoylesoftware.htmlunit.source.SVN.java
/** * Recursively deletes any '.svn' folder which contains Subversion information. * @param dir the directory to recursively delete '.svn' from * @throws IOException if an exception happens *///from w w w.j ava 2 s .c o m public static void deleteSVN(final File dir) throws IOException { for (final File f : dir.listFiles()) { if (f.isDirectory()) { if (".svn".equals(f.getName())) { FileUtils.deleteDirectory(f); } else { deleteSVN(f); } } } }
From source file:Main.java
private static void deleteFilesByDirectory(File directory) { if (directory != null && directory.exists() && directory.isDirectory()) { for (File item : directory.listFiles()) { if (item.isDirectory()) { deleteFilesByDirectory(item); }/*from w w w. java2 s. c o m*/ item.delete(); } directory.delete(); } }
From source file:Main.java
public static final boolean deleteFolder(String path) { // not recursive if (path != null && storageReady()) { File dir = new File(path); if (dir.exists() && dir.isDirectory()) { File[] files = dir.listFiles(); for (File file : files) { if (!file.delete()) { Log.i(tag, "Failed to delete " + file); }//from w w w . ja v a 2 s.co m } } return dir.delete(); } else { return false; } }
From source file:Main.java
public static boolean recursiveChmod(File root, int mode) throws Exception { boolean success = chmod(root, mode) == 0; for (File path : root.listFiles()) { if (path.isDirectory()) { success = recursiveChmod(path, mode); }//from w w w .j a v a 2 s . c om success &= (chmod(path, mode) == 0); } return success; }
From source file:it.serasoft.pdi.PDITools.java
private static void getFilesList(File f, ArrayList<File> completeFilesList, boolean recurse) { File[] files = f.listFiles(); for (File item : files) { if (recurse && item.isDirectory() && !item.isHidden()) { getFilesList(item, completeFilesList, recurse); } else if (item.isFile() && !item.isHidden() && (item.getName().endsWith(EXT_PDI_JOB) || item.getName().endsWith(EXT_PDI_TRANSFORMATION))) { completeFilesList.add(item); }/* w w w . jav a 2s.c o m*/ } }
From source file:DirectoryIO.java
/** * /*from w ww. ja va 2 s. co m*/ * recursivly delete directory * * @param directory */ public static boolean delete(File directory) { boolean result = false; if (directory.isDirectory()) { File[] files = directory.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { delete(files[i]); } files[i].delete(); } result = directory.delete(); } return result; }
From source file:bridge.toolkit.commands.MobileBuilderTest.java
static public boolean deleteDirectory(File path) { if (path.exists()) { File[] files = path.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { deleteDirectory(files[i]); } else { files[i].delete();/* w w w.j a v a 2s .c om*/ } } } return (path.delete()); }
From source file:Main.java
private static void GetFiles(File directory, ArrayList<File> files) { File[] f = directory.listFiles(); for (int i = 0; i < f.length; i++) { if (f[i].isDirectory()) { GetFiles(f[i], files);//from w ww . jav a 2s. co m } else { files.add(f[i]); } } }