public URI toURI() { try { File f = getAbsoluteFile(); String sp = slashify(f.getPath(), f.isDirectory()); if (sp.startsWith("//")) sp = "//" + sp; return new URI("file", null, sp, null); } catch (URISyntaxException x) { throw new Error(x); } }
@Deprecated public URL toURL() throws MalformedURLException { if (isInvalid()) throw new MalformedURLException("Invalid file path"); return new URL("file", "", slashify(getAbsolutePath(), isDirectory())); }
/** * Converts this abstract pathname into a <code>file:</code> URL. The * exact form of the URL is system-dependent. If it can be determined that * the file denoted by this abstract pathname is a directory, then the * resulting URL will end with a slash. * * @return A URL object representing the equivalent file URL * * @throws MalformedURLException * If the path cannot be parsed as a URL * * @see #toURI() * @see java.net.URI * @see java.net.URI#toURL() * @see java.net.URL * @since 1.2 * * @deprecated This method does not automatically escape characters that * are illegal in URLs. It is recommended that new code convert an * abstract pathname into a URL by first converting it into a URI, via the * {@link #toURI() toURI} method, and then converting the URI into a URL * via the {@link java.net.URI#toURL() URI.toURL} method. */ @Deprecated public URL toURL() throws MalformedURLException { return new URL("file", "", slashify(getAbsolutePath(), isDirectory())); }
/** * Converts this abstract pathname into a <code>file:</code> URL. The * exact form of the URL is system-dependent. If it can be determined that * the file denoted by this abstract pathname is a directory, then the * resulting URL will end with a slash. * * @return A URL object representing the equivalent file URL * * @throws MalformedURLException * If the path cannot be parsed as a URL * * @see #toURI() * @see java.net.URI * @see java.net.URI#toURL() * @see java.net.URL * @since 1.2 * * @deprecated This method does not automatically escape characters that * are illegal in URLs. It is recommended that new code convert an * abstract pathname into a URL by first converting it into a URI, via the * {@link #toURI() toURI} method, and then converting the URI into a URL * via the {@link java.net.URI#toURL() URI.toURL} method. */ @Deprecated public URL toURL() throws MalformedURLException { return new URL("file", "", slashify(getAbsolutePath(), isDirectory())); }
try { File f = getAbsoluteFile(); String sp = slashify(f.getPath(), f.isDirectory()); if (sp.startsWith("//")) sp = "//" + sp;
try { File f = getAbsoluteFile(); String sp = slashify(f.getPath(), f.isDirectory()); if (sp.startsWith("//")) sp = "//" + sp;