Skip to content

Instantly share code, notes, and snippets.

@wingyplus
Created July 24, 2011 13:28
Show Gist options
  • Save wingyplus/1102615 to your computer and use it in GitHub Desktop.
Save wingyplus/1102615 to your computer and use it in GitHub Desktop.
ls
import java.io.File;
public class ls {
public static void main(String[] args) {
if (args.length == 0) System.out.println("please input path ...");
else {
dirlist(args[0]);
}
}
private static void dirlist(String path) {
File dir = new File(path);
String[] list = dir.list();
try { System.out.println("List of " + dir.getCanonicalPath()); } catch (Exception e) { System.out.println("Error: "+e.getMessage()); }
for (String list_ : list) {
File isDir = new File(path + "/" + list_);
if (isDir.isDirectory()) list_ = list_ + File.separator;
System.out.println(list_);
}
}
}
@wingyplus
Copy link
Author

Notes

fix bug : show folder path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment