code: public static URI toURI(final File file) {
          if (file == null) {
              return null;
          }
          if (file.isAbsolute()) {
              return file.toURI();
          } else {
              try {
                  return new URI(clean(file.getPath().replace(WINDOWS_SEPARATOR, URI_SEPARATOR).trim(), false));
              } catch (final URISyntaxException e) {
                  throw new IllegalArgumentException(e.getMessage(), e);
              }
          }
      }
docs: Covert file reference to URI. The difference between this method and
  {@link java.io.File#File(URI)})} constructor is that this
  method doesn't make the URI absolute.
  
  @param file system path to convert to a URI, may be {@code null}
  @return file URI, {@code null} if input was {@code null}