Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. package myPackage;
  2.  
  3. import java.io.File;
  4.  
  5. public class Lister {
  6. private File file;
  7. private boolean showHidden;
  8.  
  9. public Lister(File file, boolean showHidden) {
  10. this.file = file;
  11. this.showHidden = showHidden;
  12. }
  13.  
  14. public void list() {
  15. this.listRecurse(file, "");
  16. }
  17.  
  18. private void listRecurse(File file, String indent) {
  19. if(file != null) {
  20. if(file.isDirectory())
  21. System.out.println(indent + file.getName());
  22. else
  23. System.out.println(file.getAbsoluteFile());
  24. listRecurse(file, indent);
  25. }
  26.  
  27. }
  28.  
  29. public static void main(String[] args) {
  30. File root = new File("/users/adamgolab/documents/lab5");
  31. root.list();
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement