Java implementation of web page parsing sample

  • 2020-04-01 03:15:58
  • OfStack

Just paste the url in the ninth line of parentheses


package com.meession.test;
import java.io.DataInputStream;
import java.net.URL;
public class Internet {
 public static void main(String args[]){
  URL myURL;
  DataInputStream myURLContent;
  try{
   myURL=new URL("//www.jb51.net");
   myURLContent=new DataInputStream(myURL.openStream());
   while(myURLContent.readLine() != null){
    String Iline=myURLContent.readLine();
    System.out.println(Iline);
   }
   myURLContent.close();
  }
  catch(Exception e){
   System.out.println("Error");
  }
 }
}


Related articles: