import java.util.*;
import java.lang.*;
import java.net.URL;
import java.net.URI;

class Main
{
    public static void main (String[] args) throws java.lang.Exception
	{
		URL url = new URL("http", "google.com", 8080, "/crapy|path with-unwise_characters.jpg");
		System.out.println(url.toString());
		System.out.println(url.getFile());

		URI uri = new URI(url.getProtocol(), 
		                  null /*userInfo*/,
		                  url.getHost(), 
		                  url.getPort(), 
		                  url.getFile(), 
		                  null /*query*/, 
		                  null /*fragment*/);

		System.out.println(uri.toString());

		try {
			url.toURI();
		} catch (java.net.URISyntaxException e) {
			System.out.println(e.toString());
		}
	}
}