code: public static String getRelativeName(File file) {
          if (!file.isAbsolute()) {
              String result = file.getPath().replace(File.separatorChar, '/');
              if (isRelativeUri(result))
                  return result;
          }
          throw new IllegalArgumentException("Invalid relative path: " + file);
      }
docs: Converts a relative file name to a relative URI.  This is
  different from File.toURI as this method does not canonicalize
  the file before creating the URI.  Furthermore, no schema is
  used.
  @param file a relative file name
  @return a relative URI
  @throws IllegalArgumentException if the file name is not
  relative according to the definition given in {@link
  javax.tools.JavaFileManager#getFileForInput}