java中FileInputStream和FileOutputStream对图片操作的例子

 package a.ab;

 import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException; public class ClassA {
public static void main(String[] args) {
try {
FileInputStream fis = new FileInputStream(
"C:\\Program Files\\feiq\\Recv Files\\001.jpg");
FileOutputStream fos = new FileOutputStream(
"C:\\Program Files\\feiq\\Recv Files\\003.jpg");
int len = 0;
byte[] bytes = new byte[1024];
try {
while ((len = fis.read(bytes)) != -1) {
fos.write(bytes, 0, len);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} }
}
上一篇:曾经的足迹——对Linux CAN驱动的理解(1)


下一篇:在线编译安装redis脚本