Created
September 6, 2014 07:16
-
-
Save resarahadian/202012af57211d118bbf to your computer and use it in GitHub Desktop.
Aplikasi File Finder
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
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