Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 0.75 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package command;
  2.  
  3. import java.io.File;
  4.  
  5. public class find {
  6.         public static void main(String[] args) {
  7.                 if (args.length == 0) System.out.println("please input path ...");
  8.                 else {
  9.                         find(args[0]);
  10.                 }
  11.         }
  12.        
  13.         private static void find(String item) {
  14.                 File dir = new File("./");
  15.                 String[] list = dir.list();
  16.                 for (String list_ : list) {
  17.                         if (list_.equals(item)) {
  18.                                 System.out.println(list_);
  19.                                 showPath(list_);
  20.                         }
  21.                 }
  22.         }
  23.        
  24.         private static void showPath(String path) {
  25.                 File dir = new File(path);
  26.                 if (dir.isFile()) {}
  27.                 else {
  28.                         String[] list = dir.list();
  29.                         for (String list_ : list) {
  30.                                 File item = new File(path + "/" + list_);
  31.                                 if (item.isDirectory()) list_ = list_ + File.separator;
  32.                                 System.out.println(path + "/" + list_);
  33.                         }
  34.                 }
  35.         }
  36. }