• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

Listing all in a root (39 Line working code)

 
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this set up :


It works 100%. But, as the code says, it only goes 2 deep. I need this to be going until it runs out of dir's to check. If it isn't a dir, I want it to stop at that dir and :

Anyway, I was thinking something along the lines of a while() statement. I just don't know how to implement it. If you could provide code or insight that would be great.

Thanks,
cc11rocks

This is what it prints out for my "D:\" drive (in case you were wondering) :
 
Ranch Hand
Posts: 312
MS IE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may use recursive programming technique, to traverse the entire depth of directory structure.
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about this? :


If you were wondering, yes I came up with all of this myself. No copying
Thanks,
cc11rocks
 
Madhan Sundararajan Devaki
Ranch Hand
Posts: 312
MS IE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may need to make the following changes.

 
Sheriff
Posts: 22037
108
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And even one more change:
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And even one more change (everything). Java 7:


 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys so much! Just to clarify, you were having the program do the same thing I was, just in a different way (and with less bugs as without "!= null" returns a NullException)?
I am currently using your method. It works 100% (with a slightly modified FileTest()).

In case you are wondering, I went through my whole hard drive. The file that I saved all the information in took up 13.5 MB of space. My CPU was going crazy. I had very little memory left.
Thank you guys again,
cc11rocks
 
You don't like waffles? Well, do you like this tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic