code: public String getResourcePath (File file)
      {
          if (_rdir == null) {
              return null;
          }
          try {
              String parent = _rdir.getCanonicalPath();
              if (!parent.endsWith(File.separator)) {
                  parent += File.separator;
              }
              String child = file.getCanonicalPath();
              if (!child.startsWith(parent)) {
                  return null;
              }
              String path = child.substring(parent.length());
              return (File.separatorChar == '/') ? path : path.replace(File.separatorChar, '/');
  
          } catch (IOException e) {
              log.warning("Failed to determine resource path", "file", file, e);
              return null;
          }
      }
docs: Given a file within the resource directory, returns a resource path that can be passed to
  {@link #getResourceFile} to locate the resource.
  
  @return a path referencing the specified resource or null if either the resource manager
  was never configured with a resource directory or the file is not contained within the
  resource directory.