Advertisement
teknoraver

URL.equals

Jul 5th, 2022
869
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None
  1. import java.net.MalformedURLException;
  2. import java.net.URL;
  3.  
  4. class Playground {
  5.     final static String urls[][] = {
  6.         {"facebook.com", "m.facebook.com"},
  7.         {"www.google.com", "www.l.google.com"},
  8.         {"www.ilfattoquotidiano.it", "www.ilfattoquotidiano.it.cdn.cloudflare.net."},
  9.         };
  10.     public static void main(String[ ] args) throws MalformedURLException {
  11.         for (String url[] : urls)
  12.             System.out.println(url[0] + " == " + url[1] + ": " +
  13.                 new URL("https://" + url[0]).equals(new URL("https://" + url[1]))
  14. );
  15.     }
  16. }
Advertisement
RAW Paste Data Copied
Advertisement