//文件上传
//FileName 为文件名
//file 为文件
//path 为文件的路径,最好是绝对路径
private static void upLoad(String path,String FileName,File file) throws Exception{
File temp = new File(ServletActionContext.getServletContext().getRealPath(path),FileName);
temp.getParentFile().mkdirs();
InputStream ins = null;
OutputStream ous = null;
ins = new FileInputStream(file);
ous = new FileOutputStream(temp);
byte[] bytes = new byte[1024];
int length = 0;
while ((length = ins.read(bytes)) != -1) {
ous.write(bytes, 0, length);
}
if (ous != null) {
ous.close();
}
if (ins != null) {
ins.close();
}
}