确定输入流的大小
2022-08-31 10:33:36
我目前的情况是:我必须读取一个文件并将内容放入.之后,我需要将 的内容放入一个字节数组中,该数组需要(据我所知)的大小。有什么想法吗?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()
}
}
该请求是一个对象,它类似于 Apache Commons FileUpload 包。HttpServletRequest
FileItemFactory
ServletFileUpload