简单的复制形式

public class Seventh02 {
public static void main(String[] args) throws IOException {
//根据数据源创建字节输入流对象
FileInputStream fis = new FileInputStream("D:\\heima\\psb.jpg");
//根据目的地创建字节流输出对象
FileOutputStream fos = new FileOutputStream("F:\\luoli2.jpg");
//读写数据,复制图片(一次读取一个字节数组,一次写入一个字节数组)
byte[] bytes = new byte[1024];//创建资格1024的字节数组
int len;//图片的字节长度
while((len = fis.read(bytes))!= -1){
fos.write(bytes,0,len);
}
//释放资源
fos.close();
fis.close();

}
}

猜你喜欢

转载自www.cnblogs.com/YRSWBY2016/p/12019133.html