IO编程__字节流__输入、输出__图片移动

一、代码如下

package www.tainiu.wenjian;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class ad__FileImage {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FileInputStream fis= null;
		FileOutputStream fos= null;
		
		try {
			fis= new FileInputStream("d:\\jscb.png");
			fos= new FileOutputStream("e:\\jscb.png");
			
			byte[] bytes= new byte[1024];
			int n= 0;
			while((n=fis.read(bytes)) != -1) {
				fos.write(bytes);
			}
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {fis.close();fos.close();} catch (Exception e) {e.printStackTrace();}
			
		}

	}

}

 

posted @ 2017-10-06 22:23  18513757531  阅读(181)  评论(0编辑  收藏  举报