I'm trying to upload a XML file (text.xml) using a simple upload html form, regulary read it as FileItem in the servlet and then get the ACTUAL file (text.xml) so i can print it, save it etc. Is there any educated way to do this simply? some people told me to use FileItem's property getInputStream.. is there any example somewhere? isn't there a shorter way?
thanks
BalusC
Just use FileItem#write()
method, exactly as demonstrated in User Guide of Apache Commons FileUpload.
File file = new File("/path/to/text.xml");
fileItem.write(file);
That's all.
See also:
来源:https://stackoverflow.com/questions/15072917/convert-fileitem-to-file