- import java.io.*;
- public class testPhotoCopy {
- public static void main(String args[]){
- FileInputStream fis = null;
- FileOutputStream fos = null;
- try {
- fis = new FileInputStream("D:\\ashk_wnd.bmp");
- fos = new FileOutputStream("c:\\ashk_wnd.bmp");
- int num = 0;
- byte[] buf = new byte[1024];
-
- while ((num = fis.read(buf))!=-1){
- fos.write(buf,0,num);
- }
-
- } catch (IOException e) {
- throw new RuntimeException("写入图片失败");
- } finally{
- try {
- if(fis!=null)
- fis.close();
- } catch (IOException e) {
- throw new RuntimeException("关闭输入流失败");
- }
- try{
- if(fis!=null)
- fos.close();
- } catch(IOException e){
- throw new RuntimeException("关闭输出流失败");
- }
- }
- }
- }
复制代码
|
|