java IO流读取保存图片文件
程序员文章站
2022-06-16 20:08:06
...
package io;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class PictureCopy {
public static void main(String[] args) throws IOException {
BufferedInputStream in = new BufferedInputStream(new FileInputStream("E://a//photo.jpg")); //原先图片所在路径
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("E://b//copyPhoto.jpg")); //你要保存在哪个目录下面
int i;
while((i=in.read())!=-1){
out.write(i);
}
out.flush();
out.close();
in.close();
}
}