Skip to content

Instantly share code, notes, and snippets.

@resarahadian
Created September 6, 2014 07:16
Show Gist options
  • Save resarahadian/202012af57211d118bbf to your computer and use it in GitHub Desktop.
Save resarahadian/202012af57211d118bbf to your computer and use it in GitHub Desktop.
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