APISonar


java.io.File.listFiles

> java > io > File > listFiles
java APIs io APIs File APIs listFiles APIs

Example 1
void _recursiveDelete(File f) {
        if (f.isDirectory()) {
            if (f.listFiles()!=null) {
                for (File r : f.listFiles()) {
                    _recursiveDelete(r);
                }
            }
        }
        f.delete();
    }
Example 2
public File[] listFiles( File directory )
    {
        return directory.listFiles();
    }
Example 3
private void corruptAllSnapshots(File snapDir) throws IOException {
        File[] listFiles = snapDir.listFiles();
        for (File f : listFiles) {
            if (f.getName().startsWith("snapshot")) {
                corruptFile(f);
            }
        }
    }
Example 4
private static void addModuleJars(List<URL> urls, File libDir) {
		if (!libDir.isDirectory()) {
			return;
		}
		File[] listFiles = libDir.listFiles();
		if (listFiles != null) {
			for (File jarFile : listFiles) {
				if (isJarFile(jarFile)) {
					addFileURL(urls, jarFile);
				}
			}
		}
	}
Example 5
public static void main(String[] args) throws Exception {
        File d = new File(".");
        go("list()", d.list());
        go("listFiles()", d.listFiles());
        go("list(null)", d.list(null));
        go("listFiles((FilenameFilter)null)", d.listFiles((FilenameFilter)null));
        go("listFiles((FileFilter)null)", d.listFiles((FileFilter)null));
    }
Example 6
File directory;

    public void clear() {
        removeFiles(directory.listFiles());
        cache.evictAll();
    }
Example 7
private File cacheDirectory;

    void deleteAllCachedFiles() {
        assert !isTemporary();
        for (File f : cacheDirectory.listFiles()) {
            f.delete();
        }
    }
Example 8
private void listFiles(File dir, List<File> results, boolean includeSubDirectories) {
        File[] found = dir.listFiles();
        if ( found != null ) {
            for ( File f : found ) {
                if (f.isDirectory()) {
                    if (includeSubDirectories) {
                        listFiles(f, results, includeSubDirectories);
                    }
                } else {
                    results.add(f);
                }
            }
        }
    }
Example 9
private File tmpDir;

  public void tearDown() throws Exception {
    for (File f : tmpDir.listFiles()) {
      if (f.isDirectory()) {
        for (File sdf : f.listFiles()) {
          sdf.delete();
        }
      }
      f.delete();
    }
    tmpDir.delete();
    files = null;
  }
Example 10
private void listFiles(File dir, ArrayList<String> list) {
		for (File f : dir.listFiles()) {
			if (f.isDirectory())
				listFiles(f, list);
			else {
				list.add(Repository.stripWorkDir(root, f));
			}
		}
	}
Example 11
private void deleteJunk(File d) {
        if (!d.exists()) {
            return;
        }
        if (d.isFile()) {
            d.delete();
        } else { // directory
            for (File cf : d.listFiles()) {
                deleteJunk(cf);
            }
            d.delete();
        }
    }
Example 12
private void addFiles(HashSet<String> files, File dir, String path) {
        File[] listfiles = dir.listFiles();
        if(listfiles == null) return;
        for(File f : listfiles) {
            String fn = f.getName();
            if(fn.equals(".") || (fn.equals(".."))) continue;
            if(f.isFile()) {
                files.add(path + "/" + fn);
            }
            else if(f.isDirectory()) {
                addFiles(files, f, path + "/" + f.getName());
            }
        }
    }
Example 13
private final File mCacheDirectory;

    public synchronized void clear() {
        for (File f : mCacheDirectory.listFiles()) {
            f.delete();
        }
    }
Example 14
protected void deleteSubdirs(File workingDir) {
        for (File f : workingDir.listFiles()) {
            if (f.isDirectory()) {
                for (File sf : f.listFiles()) {
                    logger.debug("Deleting " + sf);
                    sf.delete();
                }
                logger.debug("Deleting " + f);
                f.delete();
            }
        }
    }
Example 15
private void cleanupDestFolder(File destFolder) {
        for (File f : destFolder.listFiles()) {
            assertTrue(f.delete());
        }
    }
Example 16
private static void printDirectoryVisual(File dir, int depth, PrintStream writer) {
    File[] listFiles = dir.listFiles();
    for (int i = 0; i < listFiles.length; ++i) {
      printHeaderVisual(depth, writer);
      File file = listFiles[i];
      writer.print("+---");
      writer.print(file.getName());
      writer.println();

      if (file.isDirectory()) {
        printDirectoryVisual(file, depth + 1, writer);
      }
    }
  }
Example 17
private int countFiles(File dir)
    {
        int fileCount = 0;

        for (File f : dir.listFiles())
        {
            if (f.isFile() && f.toString().contains("-Data.db"))
            {
                fileCount++;
            }
        }
        return fileCount;
    }
Example 18
public void testListFilesWhereNonChildPathStartsWithParent() throws Exception {
      File parentDir = createDir("/parentDir");
      assertEquals(parentDir.listFiles().length, 0);
      assertEquals(createDir("/parentDir-NOT-CHILD").listFiles().length, 0);
      assertEquals(parentDir.listFiles().length, 0);
   }
Example 19
void delete(File f) {
    if (!f.isDirectory()) {
      return;
    }

    Arrays.stream(Objects.requireNonNull(f.listFiles())).forEach(this::delete);
    f.delete();
  }
Example 20
public static File[] resumeFiles() {
		File path = resumePath();
		return path.listFiles();
	}
Example 21
private void listFiles(List<File> subFiles, File parent, String suffix) {
        File[] files = parent.listFiles();
        if (files == null || files.length == 0) {
            return;
        }
        for (File f : files) {
            if (f.isFile() && f.getName().endsWith(suffix)) {
                subFiles.add(f);
            } else if (f.isDirectory()) {
                listFiles(subFiles, f, suffix);
            }
        }
    }
Example 22
public static void removeDirs(File root) {
        for (File f : root.listFiles()) {
            if (f.isDirectory()) {
                removeDirs(f);
            } else {
                f.delete();
            }
        }
        root.delete();
    }
Example 23
public void recursiveDelete(File fileOrDir)
	{
	    if(fileOrDir.isDirectory())
	    {
	        // recursively delete contents
	        for(File innerFile: fileOrDir.listFiles())
	        {
	            recursiveDelete(innerFile);
	        }
	    }

	    fileOrDir.delete();
	}
Example 24
public static File[] relevantDbFiles( File databaseDirectory )
    {
        if ( !databaseDirectory.exists() )
        {
            return new File[0];
        }

        return databaseDirectory.listFiles( STORE_FILE_FILTER );
    }
Example 25
public static void rm(File f) {
        if (f.isDirectory()) {
            for (File ff : f.listFiles()) {
                rm(ff);
            }
            f.delete();
        } else if (f.isFile()) {
            f.delete();
        }
    }