import java.io.*;
public class BufferStreamDome01 {
public static void main(String[] args) throws IOException {
long kaishi = System.currentTimeMillis();
// mothed01();
// mothed02(); //共用时:414毫秒
// mothed03(); //共用时:1821毫秒
mothed04(); //共用时:110毫秒
long jieshu = System.currentTimeMillis();
System.out.println(“共用时:” +(jieshu-kaishi)+“毫秒”);
// System.out.println(“1”);
}
//字节缓冲流一次读写一个数组
public static void mothed04() throws IOException{
BufferedInputStream bis =
new BufferedInputStream(
new FileInputStream(“D:\IDEA\src\JavaHeiMa02\src\字节流ByteStream\字节缓冲流\01_字节缓冲流.mp4”));
BufferedOutputStream bos =
new BufferedOutputStream(
new FileOutputStream(“D:\IDEA\src\JavaHeiMa02\src\字节流ByteStream\字节缓冲流\字节流复制视频\01_字节缓冲流.mp4”) );
byte[] bys = new byte[1024];
int len;
while ((len=bis.read(bys))!=-1){
bos.write(bys,0,len);
}
bis.close();
bos.close();
}
//字节缓冲流=一次读写一个字节
public static void mothed03() throws IOException{
BufferedInputStream bis =
new BufferedInputStream(
new FileInputStream("D:\\IDEA\\src\\JavaHeiMa02\\src\\字节流ByteStream\\字节缓冲流\\01_字节缓冲流.mp4"));
BufferedOutputStream bos =
new BufferedOutputStream(
new FileOutputStream("D:\\IDEA\\src\\JavaHeiMa02\\src\\字节流ByteStream\\字节缓冲流\\字节流复制视频\\01_字节缓冲流.mp4") );
int by;
while ((by=bis.read())!=-1){
bos.write(by);
}
bis.close();
bos.close();
}
// 字节流一次读写一个数组
public static void mothed02() throws IOException {
FileInputStream fis =
new FileInputStream(“D:\IDEA\src\JavaHeiMa02\src\字节流ByteStream\字节缓冲流\01_字节缓冲流.mp4”);
FileOutputStream fos =
new FileOutputStream(“D:\IDEA\src\JavaHeiMa02\src\字节流ByteStream\字节缓冲流\字节流复制视频\01_字节缓冲流.mp4”);
byte[] bys = new byte[1024];
int len;
while ((len=fis.read(bys))!=-1){
fos.write(bys,0,len);
}
fis.close();
fos.close();
}
//字节流一次读写一个字节
public static void mothed01() throws IOException {
FileInputStream fis =
new FileInputStream("D:\\IDEA\\src\\JavaHeiMa02\\src\\字节流ByteStream\\字节缓冲流\\01_字节缓冲流.mp4");
FileOutputStream fos =
new FileOutputStream("D:\\IDEA\\src\\JavaHeiMa02\\src\\字节流ByteStream\\字节缓冲流\\字节流复制视频\\01_字节缓冲流.mp4");
int by;
while ((by=fis.read())!=-1){
fos.write(by);
}
fis.close();
fos.close();
}
}