Hi, I have the requirement in which i have to copy dynamically determined files to other directories.I can do it by using the input and output streams but i am dealing with 5GB of data so i dont want the process to slow down.Can some one help me with this. Thanks, Hari
With input and output streams you can read and write big chunks to & from byte arrays. The bigger the chunk, the fewer the IO calls to the OS and fewer the physical reads, and (one would expect) all the faster. It's still going to take time with gigabytes of data, tho. I haven't used NIO at all - there might be some non-blocking streams that would let you read and write at the same time on threads managed by NIO.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
If you can use JDK 1.4, then java.nio.channels.FileChannel has transferTo() and transferFrom() methods that should be much faster, especially for large volumes of data. Otherwise, gotta use streams. And as Stan says, read a few big chunks, rather than lots of little chunks. Something like:
Also note that if you ever need to move a file rather than copy it, File has a renameTo() method that is probalbly what you want here. [ December 02, 2003: Message edited by: Jim Yingst ]