以IO流的方式,复制图片

public class Seventh {
public static void main(String[] args) {
FileInputStream fis = null;
FileOutputStream fos = null;
try{
fis = new FileInputStream("D:\\heima\\psb.jpg");
fos = new FileOutputStream("F:\\luoli.jpg");

byte[] bytes = new byte[1024];
int len;

while ((len = fis.read(bytes)) != -1){
fos.write(bytes,0,len);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} 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();
}
}
}

}
}
上一篇:滚动条样式修改


下一篇:CentOS 下运维自动化 Shell 脚本之 expect