62,630
社区成员




public class ImageCopy {
/**
* @param args
*/
public static void main(String[] args) {
FileInputStream fio =null;
FileOutputStream fos = null;
try {
fio = new FileInputStream("e:\\s.jpg");
fos = new FileOutputStream("d:\\w.jpg");
byte temp[] = new byte[1024];//缓存
//循环读取
int n=0;//记录实际读取到的字节数,实际读取了几个字节
while((n=fio.read())!=-1){
//输出到指定文件
fos.write(temp);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
try {
fio.close();
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}