Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Kulbir - 22 Dec 2005 12:48 GMT
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
abigale_carson@yahoo.com - 22 Dec 2005 13:06 GMT
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
zero - 22 Dec 2005 13:15 GMT
"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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.