package test.stream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* 通过文件流拷贝文件
* @author Frost.Yen
* @E-mail 871979853@qq.com
* @date 2016年4月13日
*/
public class TestStream02 {
public static void main(String[] args) {
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream("E:\\JAVA\\Examples\\To Learn\\src\\test\\stream\\1.jpg");
fos = new FileOutputStream("E:\\JAVA\\Examples\\To Learn\\src\\test\\stream\\a.jpg");
byte[] buf = new byte[1024];
int len = 0;
while((len=fis.read(buf))>=0){
fos.write(buf, 0, len);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if(fis!=null) fis.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
if(fos!=null) fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}