Java class.getResourceAsStream() returns incorrect byte
I have just run into a very strange problem with getResourceAsStream(). In my prod project JUnit test I read test data using getResourceAsStream(), I found that getResourceAsStream() sometimes substitutes some bytes: byte[] fileBytes = FileUtils.readFileToByteArray(new File( "resources/test/parser/test-short-enc.xml")); printBytes(fileBytes); byte[] classPathBytes = IOUtils.toByteArray(ParserTest.class .getResourceAsStream("/test/parser/test-short-enc.xml")) printBytes(classPathBytes); In this project output looks like this: D0 9A D1 80 D0 B8 D0 BC D0 B8 D0 BD D0 B0 D0 BB D0 B8 D1 81 D1 82 D0