Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

how to find the intermediate directory  RSS feed

 
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.
 
(instanceof Sidekick)
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.


 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!