Last active
December 23, 2015 12:49
-
-
Save orhanobut/6637894 to your computer and use it in GitHub Desktop.
Find a file in the given directory
Complexity = O(n!)
This file contains 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
public static File findFile(File file, String fileName){ | |
File[] files = file.listFiles(); | |
if (files == null) return null; | |
for (File f : files){ | |
if (f.isFile() && f.getName().equals(fileName)){ | |
return f; | |
} else if (f.isDirectory()){ | |
return findFile(f, fileName); | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment