This is the program to display or retrive the HTML content of a URL or Website. In the URL object 'a' is used to pass the URL name or address as argument to URL class. By using the BufferedReader and InputStreamReader the HTML content is retrived . openStream() is used open the given URL.
import java.io.*;
import java.io.*;
import java.net.*;
public class Main {
public Main () {
}
public static void main(String[] args) {
try{
URL a=new URL("http://165.165.80.80");
BufferedReader b=new BufferedReader(new InputStreamReader(a.openStream()));
while((obj=b.readLine())!=null)
{
System.out.println(obj);
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
Output
<html>
<head>
<title><----- SKCET Library -----></title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
background-color: #9CAFD1;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
<link href="_img/Style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style4 {
font-family: "Times New Roman", Times, serif;
font-weight: bold;
color: #003366;
font-size: 14px;
}
.style5 {
font-size: 12px;
color: #003366;
}
No comments:
Post a Comment