Compare URL

In this chapter you will learn:

  1. How to find out the URL Equality

URL Equality

import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
// j  av  a2s  . c o m
public class Main {
  public static void main(String[] argv) throws Exception {
    HttpURLConnection.setFollowRedirects(false);

    URL url = new URL("http://hostname:80");
    URLConnection conn = url.openConnection();

    HttpURLConnection httpConn = (HttpURLConnection) conn;
    httpConn.setInstanceFollowRedirects(false);

    conn.connect();
  }
}

The code above generates the following result.

Next chapter...

What you will learn in the next chapter:

  1. What is URLConnection
Home » Java Tutorial » URL URI
URL
URL Creation
URL for jar file
URL Components
Convert file path to URL
URL Relative
URL Protocol
Read from URL
Compare URL
URLConnection
HTTP Header
URLConnection Post
Cookie
URLConnection Read
HttpURLConnection
HttpURLConnection Properties
HttpURLConnection proxy
HttpURLConnection Authenticator
HTTPS
JarURLConnection
Encode a URL
Decode a URL
URI
URI Normalization
URI Resolution
URI Relativization
Convert URI to URL
IP Address
IP Ping
NetworkInterface