Esempio n. 1
0
 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);
   }
 }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
 public static InputStream openInputStream(Object uri) throws IOException {
   return Path.valueOf(uri).openInputStream();
 }
Esempio n. 4
0
 public Path resolve(Path relative) {
   if (relative.isAbsolute()) return relative;
   return resolve(relative.toString());
 }