}
FileUploadForm fuf = (FileUploadForm) form; 字串4
FormFile file = fuf.getFile(); 字串3
try {
if (file == null) { 字串7
log.info(">>>>>>>>>>>>>>>file为空");
字串8
return mapping.findForward("success");
字串9
} 字串5
} catch (Exception e) { 字串8
e.printStackTrace();
字串5
} 字串9
String fname = file.getFileName();
int t = 0;
字串8
for (int i = 0; i < fname.length(); i ) {
字串5
if (fname.charAt(i) == '.') {
t = i; 字串7
} 字串9
}
字串2
String filename = null; 字串8
if (t > 0) {
字串6
filename = fname.substring(0, t); 字串4
}
log.info(">>>>>>>>>>>>>>>文件名:" filename);
String filepath = path "dataimport/upfiles/" fname; 字串5
File f = new File(path "dataimport/upfiles/");
log.info(">>>>>>>>>>>>>>>文件生成路径:" filepath); 字串5
if (!f.exists()) {
字串1
f.mkdirs(); 字串1
} else { 字串6
log.info(">>>>>>>>>>>>>>>路径存在"); 字串1
}
字串2
InputStream stream = file.getInputStream(); 字串8
OutputStream os = new FileOutputStream(path "dataimport/upfiles/"
字串7
fname); 字串4
int readBytes = 0;
byte buffer[] = new byte[8192]; 字串4
while ((readBytes = stream.read(buffer, 0, 8192)) != -1) {
字串3
os.write(buffer, 0, readBytes);
} 字串2
os.close();
stream.close();
字串6
file.destroy(); 字串7
String message = "成功!";
request.setAttribute("message", message); 字串7
return mapping.findForward("success"); 字串1
} 字串8

