package zuoye;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;

public class zuoye {
public static void main(String[] args) throws Exception{
fu();
fu1();
fu2();
fu3();
}
//字节缓冲流复制文件用非数组
public static void fu() throws Exception{
BufferedInputStream a=new BufferedInputStream(new FileInputStream("D:\\timg.jpg"));
BufferedOutputStream b=new BufferedOutputStream(new FileOutputStream("E:\\a.jpg"));
int i=0;
while((i=a.read())!=-1){
b.write(i);
}
b.close();
a.close();
}
//字节缓冲流复制文件用数组
public static void fu1() throws Exception{
BufferedInputStream a=new BufferedInputStream(new FileInputStream("D:\\timg.jpg"));
BufferedOutputStream b= new BufferedOutputStream(new FileOutputStream("E:\\a1.jpg"));
byte[] c=new byte[1024*10];
int i=0;
while((i=a.read(c))!=-1){
b.write(c,0,i);
}
b.close();
a.close();
}
//字符缓冲流复制文件用非数组
public static void fu2() throws Exception{
BufferedReader a=new BufferedReader(new FileReader("D:\\timg.jpg"));
BufferedWriter b=new BufferedWriter(new FileWriter("E:\\a2.jpg"));
int i=0;
while((i=a.read())!=-1){
b.write(i);
}
b.close();
a.close();
}
//字符缓冲流复制文件用数组
public static void fu3() throws Exception{
BufferedReader a=new BufferedReader(new FileReader("D:\\timg.jpg"));
BufferedWriter b=new BufferedWriter(new FileWriter("E:\\a3.jpg"));
char[] c1=new char[1024*10];
int i=0;
while((i=a.read(c1))!=-1){
b.write(c1,0,i);
}
b.close();
a.close();
}
}

posted on 2019-03-26 15:49  ~王~  阅读(65)  评论(0编辑  收藏  举报