Last active
December 12, 2021 17:44
-
-
Save sunmeat/de31e816f0b8163fa2c8 to your computer and use it in GitHub Desktop.
recursive files finder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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