MessageStreams { @Nonnull public static <Message extends PMessage<Message, Field>, Field extends PField> Stream<Message> resource(@Nonnull String resource, @Nonnull Serializer serializer, @Nonnull PMessageDescriptor<Message, Field> descriptor) throws IOException { ClassLoader classLoader = ClassLoader.getSystemClassLoader(); InputStream in = classLoader.getResourceAsStream(resource); if(in == null) { in = MessageStreams.class.getResourceAsStream(resource); if (in == null) { throw new IOException("No such resource " + resource); } } in = new BufferedInputStream(in); return stream(in, serializer, descriptor); }  @Nonnull static Stream<Message> path(Path file,
                         Serializer serializer,
                         PMessageDescriptor<Message, Field> descriptor); @Nonnull static Stream<Message> file(File file,
                         Serializer serializer,
                         PMessageDescriptor<Message, Field> descriptor); @Nonnull static Stream<Message> resource(@Nonnull String resource,
                             @Nonnull Serializer serializer,
                             @Nonnull PMessageDescriptor<Message, Field> descriptor); @Nonnull static Stream<Message> stream(InputStream in,
                           Serializer serializer,
                           PMessageDescriptor<Message, Field> descriptor);  }
@Test public void testResource() { try { MessageStreams.resource("/no_such_resource.json", new JsonSerializer(), CompactFields.kDescriptor); fail("no exception"); } catch (IOException e) { assertThat(e.getMessage(), is("No such resource /no_such_resource.json")); } }