HEllppp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajangjr
    New Member
    • Sep 2006
    • 6

    #1

    HEllppp

    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..
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by rajangjr
    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..
    if you just want to visit a page, look at this

    Code:
    public class aaa {
                public static void main(String[] args) {
                String browserPath = "C:/Program Files/Internet  Explorer/IEXPLORE.EXE"; //Use your browser path
                    String url = "www.sun.com";
                    try {
    	     String[] b = {browserPath, url};
                         Runtime.getRuntime().exec(b);
                    }
                    catch (Exception exc) {
    	exc.printStackTrace();
                    }
        }
    }

    Comment

    • rajangjr
      New Member
      • Sep 2006
      • 6

      #3
      Originally posted by r035198x
      if you just want to visit a page, look at this

      Code:
      public class aaa {
                  public static void main(String[] args) {
                  String browserPath = "C:/Program Files/Internet  Explorer/IEXPLORE.EXE"; //Use your browser path
                      String url = "www.sun.com";
                      try {
      	     String[] b = {browserPath, url};
                           Runtime.getRuntime().exec(b);
                      }
                      catch (Exception exc) {
      	exc.printStackTrace();
                      }
          }
      }

      Thanks for the code but i dont want the user to know which website it is visited
      i dont want a browser to open a url..

      Comment

      Working...