Search code examples
javajvminputstreambuffering

Strange IOException when buffering inputStream in Java


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)

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.

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


Solution

  • 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";