/** * Constructs a <tt>file:</tt> URI that represents this abstract pathname. * * <p>The exact form of the URI is system-dependent. If it can be determined that the file denoted * by this abstract pathname is a directory, then the resulting URI will end with a slash. * * <p>For a given abstract pathname <i>f</i>, it is guaranteed that * * <blockquote> * * <tt> new {@link #GeneralFile(java.net.URI) GeneralFile} * (</tt><i> f</i><tt>.toURI()).equals(</tt><i> f</i><tt>) </tt> * * </blockquote> * * so long as the original abstract pathname, the URI, and the new abstract pathname are all * created in (possibly different invocations of) the same Java virtual machine. However, this * relationship typically does not hold when a <tt>file:</tt> URI that is created in a virtual * machine on one operating system is converted into an abstract pathname in a virtual machine on * a different operating system. * * @return An absolute, hierarchical URI with a scheme equal to <tt>"file"</tt>, a path * representing this abstract pathname, and undefined authority, query, and fragment * components * @see #GeneralFile(java.net.URI) * @see java.net.URI * @see java.net.URI#toURL() */ public URI toURI() { try { return new URI(toString()); } catch (URISyntaxException e) { if (DEBUG > 0) e.printStackTrace(); } return null; }
public static String convertUrlToBaseStringURI(URL url) { URI uri = null; try { uri = url.toURI(); } catch (URISyntaxException e1) { e1.printStackTrace(); } String scheme = uri.getScheme().toLowerCase(); String host = uri.getHost().toLowerCase(); int port = uri.getPort(); if ((scheme.equals(HTTP_PROTOCOL) && port == HTTP_DEFAULT_PORT) || (scheme.equals(HTTPS_PROTOCOL) && port == HTTPS_DEFAULT_PORT)) { port = -1; } URI baseUri = null; try { baseUri = new URI(scheme, null, host, port, uri.getPath(), null, null); } catch (URISyntaxException e) { e.printStackTrace(); } return baseUri.toString(); }
public static WMSCapabilities retrieve(URI uri) throws Exception { try { CapabilitiesRequest request = new CapabilitiesRequest(uri); return new WMSCapabilities(request); } catch (URISyntaxException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } return null; }