我目前的情况是:我必须读取一个文件并将内容放入InputStream
. 之后我需要InputStream
将InputStream
. 有任何想法吗?
根据要求,我将显示我从上传的文件创建的输入流
InputStream uploadedStream = null;
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
java.util.List items = upload.parseRequest(request);
java.util.Iterator iter = items.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();
if (!item.isFormField()) {
uploadedStream = item.getInputStream();
//CHANGE uploadedStreambyte = item.get()
}
}
请求是一个HttpServletRequest
对象,类似于Apache Commons FileUpload 包FileItemFactory
。ServletFileUpload