/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
//demo();
//demo1();
//demo2();
long st =System.currentTimeMillis();
BufferedInputStream bis = new BufferedInputStream(new FileInputStream("20.01_IO流(IO流概述及其分类).avi"));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("练习.avi"));
int len ;
while((len = bis.read()) != -1){
bos.write(len);
}
bis.close();
bos.close();
long ts = System.currentTimeMillis();
System.out.println(st-ts);
}
public static void demo2() throws FileNotFoundException, IOException {
FileInputStream fil = new FileInputStream("20.01_IO流(IO流概述及其分类).avi");
FileOutputStream fos = new FileOutputStream("练习.avi");
byte[]arr = new byte[8192];
int len;
while((len = fil.read(arr)) != -1){
fos.write(arr, 0, len);
}
fil.close();
fos.close();
}
public static void demo1() throws FileNotFoundException, IOException {
FileInputStream fil = new FileInputStream("xxx.txt");
FileOutputStream fos = new FileOutputStream("zzz.txt");
byte[] arr = new byte[2];
int len;
while((len=fil.read(arr)) != -1){
fos.write(arr, 0, len);
}
fil.close();
fos.close();
}
public static void demo() throws FileNotFoundException, IOException {
FileInputStream fil = new FileInputStream("zzz.tst");
FileOutputStream fos = new FileOutputStream("copy.txt");
byte[] arr = new byte[fil.available()] ;
/*while((i=fil.read())!=-1){
fos.write(i);
}*/
fil.read(arr);
fos.write(arr);
fil.close();
fos.close();
}
|