• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Searching for a folder in a given Path

 
Ranch Hand
Posts: 93
Eclipse IDE VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

How are you. I am writing a code to search for a Folder in a given Path. The problem is that the Path is not absolute, i.e it does not directly contains the folder i need to search. I want this utility to work something like {find . -name -depth "path"} of unix.

For example the path i have is /net/vol/local_images/spins/7.1.1 and i have to search for the folder name "SharedFolder". I have to find the SharedFolder under /net/vol/local_images/spins/7.1.1 and the output should be as below.

/net/vol/local_images/spins/7.1.1/XX/nt_i386/SharedFolder
/net/vol/local_images/spins/7.1.1/YY/nt_i386/SharedFolder
/net/vol/local_images/spins/7.1.1/MN/nt_i386/SharedFolder
/net/vol/local_images/spins/7.1.1/RN/nt_i386/SharedFolder
/net/vol/local_images/spins/7.1.1/AD/nt_i386/SharedFolder

Comments and suggestions are appreciated.

Thanks
Aditya
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What have you tried so far? And where are you stuck?

Have you looked at the java.io.File class?
 
Aditya Sirohi
Ranch Hand
Posts: 93
Eclipse IDE VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tried nothing tilll now. Just refreshing the Coderanch page to see if some one posted any ideas. I am trying now, will give an update by night(EST).
IDEAS ARE APPRECIATED. I will do the coding.
 
Marshal
Posts: 79471
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Aditya Sirohi wrote:IDEAS ARE APPRECIATED.

Please avoid writing all upper-case.
 
Aditya Sirohi
Ranch Hand
Posts: 93
Eclipse IDE VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is truely my bad. I apologize for it. I never meant to shout at any one, or rather i came to know today if you write in caps, its like shouting at some one over the internet. Sorry

Still Ideas are Appreciated.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seems like a typical recursive descent into a tree, yes?
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The java.io.File class I mentioned earlier is the key. The methods in that class will do much of what you need. But you need to work out the logical process. Here's a hint for getting started...

  • Start with a directory.
  • Get everything in that directory (files and subdirectories).
  • Iterate through each of these items...


  • Can you describe the rest of the process in English before trying to code it? That would help a lot.
     
    If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic