copying a file
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   devaki_vaki
Posted On:   Tuesday, March 23, 2004 06:13 AM

can we copy a file from one directory to anothr directory
if we can how we can copy?

Re: copying a file

Posted By:   Anonymous  
Posted On:   Friday, March 26, 2004 02:53 AM

Pls find the following code:
-----------------------------


// import this package
import java.nio.channels.FileChannel;

//Create chaneels for both source file as well desfile with paths..

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



// Create channel on the destination

FileChannel dstChannel = new FileOutputStream("dstFileName").getChannel();



// Copy file contents from source to destination

dstChannel.transferFrom(srcChannel, 0, srcChannel.size());



// Close the channels

srcChannel.close();

dstChannel.close();


Hope this helps

Re: copying a file

Posted By:   Christopher_Koenigsberg  
Posted On:   Tuesday, March 23, 2004 06:34 AM

What do you mean by "we"?

About | Sitemap | Contact