Online Java Compiler By
JavaTpoint.com
import java.io.*; import java.net.*; public class URLhashCodeExample2 { public static void main(String args[]) throws IOException { //passing url in constructor URL url1=new URL("https://www.javatpoint.com/java-threadpoolexecutor"); URL url2 =new URL("https://www.javatpoint.com/java-threadpoolexecutor"); //comparing url with other object if(url1.hashCode()==url2.hashCode()) System.out.println("Both URL Matching"); else System.out.println("Both URL different"); BufferedReader br=new BufferedReader(new InputStreamReader(url1.openStream())); String in; while((in=br.readLine().toString())!=null) { System.out.println(in); } br.close();} }
Output