ObjectInputStream happy with FileInputStream, not happy with getResourceAsStream
I have some pretty standard code which takes in a serialized object from a stream, which bascially looks like this: Object getObjectFromStream(InputStream is) { ObjectInputStream ois = new ObjectInputStream(is); return ois.readObject(); } I then have a file in my resources folder, so on my development machine, I can either reference it as a File, or as a JarResource: InputStream is = new FileInputStream("/home/.../src/main/resources/serializedObjects/testObject"); InputStream is = this.getClass().getResourceAsStream("/serializedObjects/testObject"); In my head, both should do the exact same