???????????????????????????????????У?????????????????????????????????java??IO???????????????org.apache.commons.io.FileUtils????????????????£?????????????????Ч???apache????????Ч???????io???????3????
??????????????????
public class ImageTest {
public static void main(String[] args) throws IOException {
IOTest();
}
public static void fileUtilsTest() throws IOException {
// ????13???????????????
File srcFile = new File("D:/1.apk");
File destFile = new File("E:/2.apk");
long sum = 0;
for (int i = 0; i < 10; i++) {
long startTime = System.currentTimeMillis();
FileUtils.copyFile(srcFile?? destFile);
long endTime = System.currentTimeMillis();
sum += (endTime - startTime);
}
long average = sum / 10;
System.out.println("???" + average + "????");
}
public static void IOTest() throws IOException {
// 50????
File srcFile = new File("D:/1.apk");
File destFile = new File("E:/2.apk");
long sum = 0;
for (int i = 0; i < 10; i++) {
long startTime = System.currentTimeMillis();
InputStream is = new FileInputStream(srcFile);
// ????д???????????·????
OutputStream os = new FileOutputStream(destFile);
byte[] buffer = new byte[400];
int length = 0;
while ((length = is.read(buffer)) > 0) {
os.write(buffer?? 0?? length);
}
is.close();
os.close();
long endTime = System.currentTimeMillis();
sum += (endTime - startTime);
}
long average = sum / 10;
System.out.println("???" + average + "????");
}
}