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: 148

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:


    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:1289

    How to send email to JSP Java

    How to send email to JSP Java
    Topic: Programming

    Tags: java,jsp,send email,email

    Views:745

    Installing Apache Tomcat to work in Java JSP

    Installing Apache Tomcat to work in Java JSP
    Topic: Programming

    Tags: java,jsp,сервер,apache tomcat

    Views:272