我正在实现一个与 resumable.js 一起使用的文件上传 servlet
每次我尝试读取文件时,我都会收到 NoSuchElement 异常或 NumberFormatException,其中包含我正在读取的文件中的字符串。我确定我在某个地方打了个嗝,但似乎无法分辨
这是我用来读取请求和写入文件的片段
if(ServletFileUpload.isMultipartContent(request)){
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setRepository(new File(temp_dir));
ServletFileUpload upload = new ServletFileUpload(factory);
Iterator<FileItem> iter = upload.parseRequest(request).iterator();
FileItem item = iter.next();
OutputStream out;
try {
out = new FileOutputStream(new File(dest_dir));
IOUtils.copy(item.getInputStream(), out);
logger.debug("Wrote file " + resumableIdentifier + " with chunk number "
+ resumableChunkNumber + " to " + temp_dir);
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
}
}
我是否做错了什么使代码实际读取和解释文件的内容?