代码如下
private String myFileFileName;
private static int BUFFER_SIZe=16*1024;
private String myFileContentType;
private String imageFileName;
private String caption;
private File myFile; private static void copy(File src ,File dst){
InputStream in=null;
OutputStream out=null;
try{
in = new BufferedInputStream(new FileInputStream(src),BUFFER_SIZe);
out= new BufferedOutputStream(new FileOutputStream(dst),BUFFER_SIZe);
byte [] buffer = new byte [BUFFER_SIZe];
while (in.read()>0){
out.write(buffer);
}
}catch(Exception ex){
ex.printStackTrace();
}finally{
if(null!=in){
try {
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(null!=out){
try {
out.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}

private static String getExtention (String fileName){
int pos = fileName.lastIndexOf(".");
return fileName.substring(pos);
}

public String execute(){
imageFileName= new Date().getTime()+getExtention(myFileFileName);
System.out.println(imageFileName);
File imageFile = new File(ServletActionContext.getServletContext().getRealPath("/UploadImages")+"/"+myFileFileName);
System.out.println(imageFile);
copy(myFile,imageFile);
return SUCCESS;

}程序运行后 没什么错误 就是上传图片 图片文件损坏 打不开了 这个是什么问题造成的呢 知道的麻烦说下 谢谢