public static URL toURL(String str) { try { if (!Path.uriSchemeSpecified(str)) { Path cur = currentPath(); Path path = cur.resolve(str); if (path.isAbsolute()) return path.toURL(); str = path.toString(); } return new URL(str); } catch (Throwable ex) { throw WrappedException.wrapIfNeeded(ex); } }
public static Path coerceToPathOrNull(Object path) { if (path instanceof Path) return (Path) path; if (path instanceof URL) return URLPath.valueOf((URL) path); /* #ifdef use:java.net.URI */ if (path instanceof URI) return URIPath.valueOf((URI) path); /* #endif */ if (path instanceof File) return FilePath.valueOf((File) path); String str; if (path instanceof gnu.lists.FString) // FIXME: || UntypedAtomic str = path.toString(); else if (!(path instanceof String)) return null; else str = (String) path; if (Path.uriSchemeSpecified(str)) return URIPath.valueOf(str); else return FilePath.valueOf(str); }