import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
// 高效字节流赋值
public class Test3 {
public static void main(String[] args) throws IOException {
String dio = "01回顾.wmv";
File f = new File("C:\\Users\\Administrator\\Desktop\\Test",dio);
File of = new File("C:\\Users\\Administrator\\Desktop\\Test\\tv\\a.wmv");
// if(!f.exists()) {
// boolean mkdirs = f.mkdirs();
// System.out.println(mkdirs);
// }
FileInputStream fil = new FileInputStream(f);
FileOutputStream fos = new FileOutputStream(of);
BufferedInputStream bfi = new BufferedInputStream(fil);
BufferedOutputStream bfo = new BufferedOutputStream(fos);
int i = 0;
//shuzu(bfi, bfo);//247
//sig(bfi, bfo);//4276
bfi.close();
fil.close();
bfo.close();
fos.close();
}
private static void sig(BufferedInputStream bfi, BufferedOutputStream bfo) throws IOException {
int i;
long s = System.currentTimeMillis();
while((i = bfi.read()) != -1) {
bfo.write(i);
}
long e = System.currentTimeMillis();
System.out.println(e-s);
}
private static void shuzu(BufferedInputStream bfi, BufferedOutputStream bfo) throws IOException {
int i;
byte[] c = new byte[1024];
long s = System.currentTimeMillis();
while((i = bfi.read(c)) != -1) {
bfo.write(c);
}
long e = System.currentTimeMillis();
System.out.println(e-s);
}
}
java小数组高效拷贝和单个字符拷贝效率对比
最新推荐文章于 2024-04-29 23:55:55 发布