import java.io.*;
import java.net.*;
public class aaa{
public aaa() {
}
public boolean visitWebPage(St ring UrlToVisit) {
boolean urlVisited = false;
try {
java.net.URL url = new java.net.URL(Ur lToVisit);
java.net.URLCon nection urlConnection = url.openConnect ion();
BufferedReader htmlPage = new BufferedReader( new InputStreamRead er(url.openStre am()));
String line = "";
while((line = htmlPage.readLi ne()) != null) {
System.out.prin tln("hi");
System.out.prin tln(line);
}
htmlPage.close( );
urlConnection = null;
urlVisited = true;
} catch(Exception e) {
urlVisited = false;
}
return urlVisited;
}
public static void main(String[] args) {
aaa urlVisit = new aaa();
String url = null;
String commstart = " <!-- *************** ******** ";
String commend = " *************** ******** -->";
url ="http://www.yahoo.com" ;
System.out.prin tln(commstart + "Visiting "+ url + commend);
if (urlVisit.visit WebPage(url)) {
System.out.prin tln(commstart + url + " visited" + commend);
} else {
System.out.prin tln(commstart + url + " Website not found" +commend);
}
}
}
I am trying to check whether the specified website is visited or not...but i am not able to establish a connection ..else part is displayed all the time helpp me out...
waiting for ur replies..
import java.net.*;
public class aaa{
public aaa() {
}
public boolean visitWebPage(St ring UrlToVisit) {
boolean urlVisited = false;
try {
java.net.URL url = new java.net.URL(Ur lToVisit);
java.net.URLCon nection urlConnection = url.openConnect ion();
BufferedReader htmlPage = new BufferedReader( new InputStreamRead er(url.openStre am()));
String line = "";
while((line = htmlPage.readLi ne()) != null) {
System.out.prin tln("hi");
System.out.prin tln(line);
}
htmlPage.close( );
urlConnection = null;
urlVisited = true;
} catch(Exception e) {
urlVisited = false;
}
return urlVisited;
}
public static void main(String[] args) {
aaa urlVisit = new aaa();
String url = null;
String commstart = " <!-- *************** ******** ";
String commend = " *************** ******** -->";
url ="http://www.yahoo.com" ;
System.out.prin tln(commstart + "Visiting "+ url + commend);
if (urlVisit.visit WebPage(url)) {
System.out.prin tln(commstart + url + " visited" + commend);
} else {
System.out.prin tln(commstart + url + " Website not found" +commend);
}
}
}
I am trying to check whether the specified website is visited or not...but i am not able to establish a connection ..else part is displayed all the time helpp me out...
waiting for ur replies..
Comment