Url2Uri

URI uri = null;
URL url = null;

// Create a URI
try {
    uri = new URI("file://D:/almanac1.4/Ex1.java");
} catch (URISyntaxException e) {
}

// Convert an absolute URI to a URL
try {
    url = uri.toURL();
} catch (IllegalArgumentException e) {
    // URI was not absolute
} catch (MalformedURLException e) {
}

// Convert a URL to a URI
try {
    uri = new URI(url.toString());
} catch (URISyntaxException e) {
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.