• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to find the intermediate directory  RSS feed

 
mythily prakash
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I want to get a class file which is stored in one location like
"C:/m1/m2/m3/m4/m5/.../m10/stcm.class" and i stord my java source file in another location called "C:/m1/m2/m3/m3/StringComparison/m4/m5.../m10/stcm.java".I want to copy the class file and source file to other location called " C:/m1/m2/".
This is my case and know the location of class file exactly and in case of java file i dont know the intermediate dir ../StringComparison/... and it is not a staic one.According to the filename it will change,that is, if my clas name is "lemd" then the dir name is "LengthMethod".
Pls help me to get it.Very Urgent.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like you will have to search for the files you want to move. Have you done recursive directory searching with File.list()? You could write your own getFullPath method that finds a given file:

fullPath = getFullPathFor( "name.ext" );

If you're going to do a lot of these, you might want to find all files in the directory and keep their paths in a Map. As long as the "name.ext" names are unique you could use the map to get the full path very quickly.

Are you comfortable with File? With Recursion? With Maps? If not, ask about the confusing bits. If this sounds like a good direction, see how much you can get working and show us what you make!
[ March 13, 2006: Message edited by: Stan James ]
 
mythily prakash
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi folks,
I got the way at last.Thanks to my guide Mr.srinivas.
Here dir is the location of the source file and all the files inseide this are listed,then it will be attached to the remaining things u know and will check whether it exists or not.


  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!