Created
July 24, 2011 13:28
-
-
Save wingyplus/1102615 to your computer and use it in GitHub Desktop.
ls
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.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_); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Notes
fix bug : show folder path