• Post Reply Bookmark Topic Watch Topic
  • New Topic

Searching for a folder in a given Path  RSS feed

 
Ranch Hand
Posts: 93
Eclipse IDE Linux VI Editor
  • Mark post as helpful
  • send pies
  • 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
Java Mac Safari
  • Mark post as helpful
  • send pies
  • 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 Linux VI Editor
  • Mark post as helpful
  • send pies
  • 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: 56600
172
  • Mark post as helpful
  • send pies
  • 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 Linux VI Editor
  • Mark post as helpful
  • send pies
  • 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
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems like a typical recursive descent into a tree, yes?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • 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.
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!