If you use a file system such as Luncene or Hadoop, there are a large number of index files to be distributed, you can use ready-made distribution tools, or you can write your own program for quick file copy;
Use NIO make quick copies of files
Package com.daily;
Import Java.io.File;
Import Java.io.FileInputStream;
Import Java.io.FileOutputStream;
Import java.io.IOException;
Import Java.nio.channels.FileChannel;
/**
*nio fast file copy, maxcount=128m, copy 351M files, 11001 (MS)
* the same file, with (*1024 * 1024x768)-(18192 * 1024x768), time-consuming (milliseconds)
* @author Fan Fangming
*/
public class Easyfastcopy {
Publicvoid fileCopy (string in, string out) throws IOException {
Filechannelinchannel = new FileInputStream (new File (in)). Getchannel ();
Filechanneloutchannel = new FileOutputStream (new File). Getchannel ();
try{
// If the memory is large, this value can be expanded appropriately, and there are advantages to copying large files .
Intmaxcount = (128 * 1024 * 1024);
Intmaxcount = (8 * 1024 * 1024);
int MaxCount = (64 * 1024 * 1024)-(32 *1024);
Longsize = Inchannel.size ();
longposition = 0;
while (position < size) {
position+= Inchannel
. TransferTo (Position,maxcount, Outchannel);
}
}finally {
if (Inchannel! = null) {
Inchannel.close ();
}
if (Outchannel! = null) {
Outchannel.close ();
}
}
}
publicstatic void Main (string[] args) throws Exception {
Longstart = System.currenttimemillis ();
Easyfastcopycopy = new Easyfastcopy ();
Copy.filecopy ("D:/ffm83/big.rar", "D:/ffm83/temp/big.rar");
Longend = System.currenttimemillis ();
System.out.println (" Fast File copy time:" + (End-start) + "( ms)");
}
}
A good memory is better than a bad pen. 5-java Quick File Copy