Read or get contents of a url in java

Get contents of a url in java

package com.w3spoint;
 
import java.io.InputStream;
import java.net.URL;
 
public class URLTest {
  public static void main(String args[]){
	try {
	    URL url = new URL("https://www.w3schools.blog");
	    InputStream inputStream  = url.openStream();
            byte[] b = new byte[8];
            while(inputStream.read(b) != -1){
                System.out.print(new String(b));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
  }
}
Content Protection by DMCA.com
Please Share