fileitem

Convert FileItem to File

拈花ヽ惹草 提交于 2019-12-05 22:48:07
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: How do I set the folder for storing