我目前的情况是:我必须读取文件并将内容放入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
对象,类似于FileItemFactory
和ServletFileUpload
,来自Apache Commons FileUpload包。