@Override
  public int read(byte[] b, int off, int len) throws IOException {

    // must return 0 for zero-length arrays
    if (b.length == 0 || len == 0) {
      return 0;
    }

    // will get an error from TSK if we try to read an empty file
    if (this.length == 0) {
      return -1;
    }

    if (position < length) {
      // data remains to be read

      final int lenToRead = (int) Math.min(len, length - position);

      try {
        final int lenRead = content.read(b, position, lenToRead);

        if (lenRead == 0 || lenRead == -1) {
          // error or no more bytes to read, report EOF
          return -1;
        } else {
          position += lenRead;
          return lenRead;
        }
      } catch (TskException ex) {
        throw new IOException(ex);
      }
    } else {
      // at end of file
      return -1;
    }
  }