Here's a link to a thread where this is already covered:
http://groups.google.com/group/comp.lang.java.programmer/browse_frm/thread/820ed
8b162c475a6/a5f8a82824f6efe6?lnk=st&q=copy+recursively+%7Edirectory+java+how-to&
rnum=1&hl=en#a5f8a82824f6efe6
or, if the link breaks:
http://linkfrog.net/dacs
Hope this helps,
Abigale
"Kulbir" <kb.singh1978@gmail.com> wrote in news:1135255705.007520.164500
@f14g2000cwb.googlegroups.com:
> Hi ,
> can any body help me, how i can copy all files from one directory to
> another in java. suppose i have a source directory called abc/def in
> which i have 20 files. i want to copy all the files from this direcory
> to xxx/yyy directory. can any body suggest me by code sample.
> thanks
First you use File:list() to get all files in the directory. Then, you can
use FileChannel:transferTo to copy the file.
FileChannel in = new FileInputStream(fFile).getChannel();
FileChannel out = new FileOutputStream(fDest).getChannel();
in.transferTo(0, in.size(), out);

Signature
Beware the False Authority Syndrome