Apache FileItem 到字节数组?

Apache FileItem to byte array?

我正在使用,

org.​apache.​commons.​fileupload.​FileItem

我想使用 JSP Servlet 上传文件,

<form action="someAction" method="post"  enctype="multipart/form-data">

有没有办法将这个 file/item 转换为字节数组?目前,我已经在我的 servlet 中完成了,

        List<FileItem> multiparts = upload.parseRequest(req);
        for (FileItem item : multiparts) {
            if (!item.isFormField()) {
                //Custom class need byte array as the file's content
                CustomClass doc = new CustomClass();
                //Need to set byte array value to this
                doc.setValue(byte array);
                item --> byte array????
            }
        }

来自 javadoc(重点是我的):

After retrieving an instance of this class from a FileUpload instance (see #parseRequest(javax.servlet.http.HttpServletRequest)), you may either request all contents of the file at once using get() or request an InputStream with getInputStream() and process the file without attempting to load it into memory, which may come handy with large files.