Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Aplikasi File Finder
import java.io.*;
import java.util.*;
class SearchFileApp {
public void findFile(String name, File file) {
File[] list = file.listFiles();
if (list != null)
for (File fil : list) {
if (fil.isDirectory()) {
findFile(name, fil);
} else if (name.equalsIgnoreCase(fil.getName())) {
System.out.println(fil.getParentFile());
}
}
}
public static void main(String[] ar) {
SearchFileApp sf = new SearchFileApp();
System.out.println("============= >File Finder App< =============");
@SuppressWarnings("resource")
Scanner scan = new Scanner(System.in);
System.out.println("Masukkan nama file yang ingin dicari.. ");
String name = scan.next();
System.out.println("========================================");
System.out.println("Masukkan lokasi pencarian.. (/home/) ");
String directory = scan.next();
System.out.println("========================================");
System.out.println(">Process Pencarian<");
sf.findFile(name, new File(directory));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment