import java.io.*;
public class Dump {
public static void main(String[]args) {
try
{
dump( new FileInputStream("aaa.bmp"),
new FileOutputStream("bbb.bmp"));
}//文件输入aaa.bmp,文件输出bbb.bmp(文件复制)
catch(FileNotFoundException fex)
{
fex.printStackTrace();
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
}
public static void dump(InputStream src, OutputStream dest)
throws IOException//抛出可能的IO异常
{
InputStream input = new BufferedInputStream(src);
OutputStream output = new BufferedOutputStream(dest);
//处理复制过程,先通过一个缓冲区
byte[] data = new byte[1024]; //字节数组,1024个字节
int length = -1;
while ((length = input.read(data)) != -1) {
output.write(data, 0, length);//写出,data缓冲区里面从第0个开始,length长
}
input.close();
output.close();
}
}

