menu


Subscribe to the blog

Social networks

My page on vk.com
My page on Facebook
My page on Google plus
My page on Twitter

Main - Blog - http request and read the html page Java

Programming Date of creation: Views: 143

http request and read the html page Java

lesnih.info


Russia

import java.net.*;
import java.io.*;

public class NewClass {
    public static void main(String[] args) throws Exception {
        
        System.out.println("Start");
        URL oracle = new URL("https://lesnih.info/");
        BufferedReader in = new BufferedReader(
        new InputStreamReader(oracle.openStream()));

        String Line;
        StringBuilder sb = new StringBuilder();
        while ((Line = in.readLine()) != null)
            sb.append(Line);
        
        System.out.println(sb); 
        
        System.out.println("The end"); 
    }
}



Another option with line output

import java.net.*; 
import java.io.*; 

public class NewClass { 
    public static void main(String[] args) throws Exception { 
     URL blog = new URL("https://lesnih.info/"); 
     URLConnection lv = blog.openConnection(); 
     BufferedReader in = new BufferedReader(
           new InputStreamReader(
           lv.getInputStream())); 
     String Line; 

     while ((Line = in.readLine()) != null) 
      System.out.println(Line); 
     in.close(); 
    } 


http request and read the html page Java
Rating: 5 | Тotal votes: 1 | Please, rate this article




Commets:









    Subscribe to the blog


    Random articles from the blog:


    Mysql Java - SELECT data from Mysql - Java

    Mysql Java - SELECT data from Mysql - Java
    Topic: Programming

    Tags: java,mysql,select

    Views:247

    Java XML - Reading XML in a java application

    Java XML - Reading XML in a java application
    Topic: Programming

    Tags: java,xml,reading xml,integration,exchange

    Views:338

    Java XML - XML record in a java application

    Java XML - XML record in a java application
    Topic: Programming

    Tags: java,xml,write xml,integration,exchange

    Views:1282