Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > help me! how can i copy all files from one directory to another in java

Reply
Thread Tools

help me! how can i copy all files from one directory to another in java

 
 
Kulbir
Guest
Posts: n/a
 
      12-22-2005
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

 
Reply With Quote
 
 
 
 
abigale_carson@yahoo.com
Guest
Posts: n/a
 
      12-22-2005
Here's a link to a thread where this is already covered:

http://groups.google.com/group/comp....f8a82824f6efe6

or, if the link breaks:

http://linkfrog.net/dacs

Hope this helps,

Abigale

 
Reply With Quote
 
 
 
 
zero
Guest
Posts: n/a
 
      12-22-2005
"Kulbir" <(E-Mail Removed)> 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);


--
Beware the False Authority Syndrome
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How Do You Copy 60 Million Files From One Windows Server To Another? Lawrence D'Oliveiro NZ Computing 4 10-05-2010 09:43 AM
show all files in the directory, but how to show directory control?? strutsng@gmail.com HTML 1 09-30-2005 07:32 AM
show all files in the directory, but how to show directory control?? strutsng@gmail.com ASP General 1 09-30-2005 07:32 AM
how to copy all style attributes from one to another object Gerrit Horeis Javascript 1 08-12-2004 09:54 AM
list all css files in a directory and sub directory TJS ASP .Net 1 06-23-2004 10:49 AM



Advertisments