/*
 * [TestURL.java]
 *
 * Summary: Test behaviour of URL constructor.
 *
 * Copyright: (c) 2012-2017 Roedy Green, Canadian Mind Products, http://mindprod.com
 *
 * Licence: This software may be copied and used freely for any purpose but military.
 *          http://mindprod.com/contact/nonmil.html
 *
 * Requires: JDK 1.8+
 *
 * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/
 *
 * Version History:
 *  1.0 2012-10-31 original version
 */
package com.mindprod.example;

import java.io.IOException;
import java.net.URL;

import static java.lang.System.*;

/**
 * Test behaviour of URL constructor.
 *
 * @author Roedy Green, Canadian Mind Products
 * @version 1.0 2012-10-31 original version
 * @since 2012-10-31
 */
public final class TestURL
    {
    /**
     * Examines Java's various UTF implementations for conformance with Unicode Standards.
     *
     * @param args not used
     *
     * @throws java.io.IOException on I/O failure
     */
    public static void main( String[] args ) throws IOException
        {
        // the URL constructor computes a new URL from an url and a relative URL.
        // It works just the way you think it should.
        URL baseURL = new URL( "http://www.truesoft.org/x/submit.php" );
        out.println( baseURL );
        // >> http://www.truesoft.org/x/submit.php
        out.println( new URL( baseURL, "/submit/check-pad.php" ) );
        // >> http://www.truesoft.org/submit/check-pad.php
        out.println( new URL( baseURL, "submit/check-pad.php" ) );
        // >> http://www.truesoft.org/x/submit/check-pad.php
        out.println( new URL( baseURL, "./submit/check-pad.php" ) );
        // >> http://www.truesoft.org/x/submit/check-pad.php
        out.println( new URL( baseURL, "../submit/check-pad.php" ) );
        // >> http://www.truesoft.org/submit/check-pad.php
        baseURL = new URL( "http://www.truesoft.org/submit.php" );
        out.println( baseURL );
        // >> http://www.truesoft.org/submit.php
        out.println( new URL( baseURL, "/submit/check-pad.php" ) );
        // >> http://www.truesoft.org/submit/check-pad.php
        out.println( new URL( baseURL, "submit/check-pad.php" ) );
        // >> http://www.truesoft.org/submit/check-pad.php
        out.println( new URL( baseURL, "./submit/check-pad.php" ) );
        // >> http://www.truesoft.org/submit/check-pad.php
        out.println( new URL( baseURL, "../submit/check-pad.php" ) );
        // >> http://www.truesoft.org/../submit/check-pad.php
        }
    }