code: private static int readResource(DocPath resource, InputStream in, byte[] buf) throws ResourceIOException {
          try {
              return in.read(buf);
          } catch (IOException e) {
              throw new ResourceIOException(resource, e);
          }
      }
docs: Reads from an input stream opened from a given resource into a given buffer.
  If an IOException occurs, it is wrapped in a ResourceIOException.
  
  @param resource the resource for the stream
  @param in the stream
  @param buf the buffer
  @return the number of bytes read, or -1 if at end of file
  @throws ResourceIOException if an exception occurred while reading the stream