只写了一个复制图片的功能:
import java.io.*;
class CopyPic{
public static void main(){
FileOutputStream fos=null;
FileIntputStream fis=null;
try{
fos=new FileOutputStream(c:\\2.jpg);
fis=new FileIutputStream(c:\\1.jpg);
byte [] buf=new byte[1024];
int len=0;
while((len=fis.read(buf))!=-1){
fos.write(buf,0,len);
}
}catch(IOException e){
throw new RuntimeException("复制文件失败");
}finally{
try{
if(fis!=null)
fis.close();
}catch(IOException e){
throw new RuntimeException("读取关闭失败");
}
try{
if(fos!=null)
fos.close();
}catch(IOException e){
throw new RuntimeException("写入关闭失败");
}
}
}
}
|