• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to copy the entire directory structure  RSS feed

 
koushik maiti
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai all,
now i am facing this problem to make a copy of an entire directory structure to another destination thorugh java program...please help me as soon as possible..iam looking forward ur answers...plz send me any source code....bye..
koushik
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think your answer will be one directory at a time and one file at a time within directories. Look into the methods on the File class to get a list of what's in a directory, tell files from subdirectories, etc. One part of your program will work through these lists; recursion for subdirectories is a common approach.

Another part of your program will copy files. I still haven't caught up with NIO so I read and write byte arrays. You can do much better with NIO.

Any of that help?
 
Casper Maxwell
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

These tips may help you too:

How to follow a directory structure
http://www.java-tips.org/content/view/306/2/

How to copy one file to another through channel
http://www.java-tips.org/content/view/490/2/
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!