private static void copyPic(String resPicPath,String tarPicPath){
BufferedInputStream is=null;
BufferedOutputStream os=null;
byte[] buf=new byte[1024];
int len=0;
try {
is=new BufferedInputStream(new FileInputStream(resPicPath));
os=new BufferedOutputStream(new FileOutputStream(resPicPath));
while ((len=is.read(buf))!=-1) {
System.out.println("laile");
os.write(buf,0,len);
os.flush();
}
} catch (FileNotFoundException e) {
throw new RuntimeException("文件未找到!") ;
} catch (IOException e) {
e.printStackTrace();
}
finally{
if (is!=null) {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (os!=null) {
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
问下大神,这个程序出错在哪里,每次运行都会将原图片摧毁,还复制不成功。定义在while循环里的打印语句也不运行。。
|