1:项目结构
2:代码
1:CopyFile
package tianyi.demo4;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.DecimalFormat;
public class CopyFile extends Thread {
public File older;// 源文件路径
public File newer;// 复制目标路径
public CopyFile(String older, String newer) {
this.older = new File(older);
this.newer = new File(newer);
}
@Override
public void run() {
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(older);
fos = new FileOutputStream(newer);
byte[] b = new byte[1024];// 声明一个字节数组,每次读取的数据存到该字节数组里
int length =