在Java中缓冲inputStream时出现奇怪的IOException [英] Strange IOException when buffering inputStream in Java
问题描述
关于缓冲pdf和odt文件的inputStream,我有一个奇怪的问题.它们不是很大,只有5到15页,但最终总是这样
I have a weird issue regarding buffering inputStream of pdf and odt files. They are not so big, just 5 - 15 pages, but it always ends up like this
java.io.IOException: Stream closed
at java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:134)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
at java.io.FilterInputStream.read(FilterInputStream.java:90)
您可以在此处查看源代码.我在这里问,因为这似乎不是Apache Tika问题,而是JVM问题.
You can see the source code here. I'm asking here, because it doesn't seem to be Apache Tika issue, but rather JVM issue.
很抱歉,这样一个愚蠢的问题,是凌晨4点:-)问题是5个测试中有4个失败,所以我期望classloader找到了那些资源,但没有找到.有一个错字文件" ... Stil不明白为什么其中一个通过了
EDITED: Sorry guys for such a stupid question, it was 4am :-) The problem was that 4 from 5 tests failed so I anticipated that classloader found those resources, but it didn't. There was a typo "file / files" ... Stil don't understand why one of them passed
推荐答案
很抱歉提出一个明显的问题,但是您要加载的资源文件是否可以在测试的类路径中访问?
Sorry to ask an obvious question, but are the resource files that you're trying to load accessible in the test's classpath?
String resourceLocation = "file/Designandrealizationofanintranetportal.pdf";
这篇关于在Java中缓冲inputStream时出现奇怪的IOException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!