Skip to content

Instantly share code, notes, and snippets.

@sunmeat
Last active December 12, 2021 17:44
Show Gist options
  • Save sunmeat/de31e816f0b8163fa2c8 to your computer and use it in GitHub Desktop.
Save sunmeat/de31e816f0b8163fa2c8 to your computer and use it in GitHub Desktop.
recursive files finder
package com.alex.recursion;
import java.io.File;
import java.io.IOException;
public class AllFiles {
static int totalCount = 0;
static void listAll(String path)
throws IOException {
try {
File dir = new File(path);
File[] list = dir.listFiles();
for (File f : list) {
if (f.isFile()) {
System.out.println(++totalCount + ") " + f.getCanonicalPath());
Thread.sleep(50);
} else {
listAll(f.getCanonicalPath());
}
}
} catch (Exception e) {
}
}
public static void main(String[] args) throws IOException {
listAll("C:\\android\\studio\\");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment