Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » How to copy file
How to copy file [message #100835] Fri, 03 October 2003 01:43 Go to next message
Eclipse UserFriend
Originally posted by: MZ.whitehouse.gob

How can I copy java.io.File from one location to another without reading
it and then writing it?
Thanks
Re: How to copy file [message #100938 is a reply to message #100835] Fri, 03 October 2003 06:36 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

MZ wrote:
> How can I copy java.io.File from one location to another without reading
> it and then writing it?

What about using FileChannel (requires JDK 1.4)?

//Create channel on the source
FileChannel srcChannel = new FileInputStream(inputFile).getChannel();

//Create channel on the destination
FileChannel dstChannel = new FileOutputStream(outputFile).getChannel();

//Copy file contents from source to destination
dstChannel.transferFrom(srcChannel, 0, srcChannel.size());

//Close the channels
srcChannel.close();
dstChannel.close();

HTH,

Frank
Re: How to copy file [message #103167 is a reply to message #100835] Fri, 10 October 2003 15:39 Go to previous message
Eclipse UserFriend
Originally posted by: John_Arthorne.oti.com_

This is a trick question, right?

If someone comes up with a technique for copying files that doesn't
require any reading or writing, we'd all like to hear about it :)
--

MZ wrote:
> How can I copy java.io.File from one location to another without reading
> it and then writing it?
> Thanks
>
Previous Topic:Lock files from a cvs repository in eclipse.
Next Topic:Cannot start Eclipse under AIX
Goto Forum:
  


Current Time: Fri May 23 07:08:19 EDT 2025

Powered by FUDForum. Page generated in 0.04122 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top