Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Testing whether a list of URLs are active or not in java?

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Testing whether a list of URLs are active or not in java?

    I am trying to test a list of ip addresses in a local network. Currently the way I do it is by passing each ip through the following method:

    public static void testURL(String strUrl) throws Exception {
     
    try {
    URL url = new URL(strUrl);
    HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
    urlConn.connect();
     
    assertEquals(HttpURLConnection.HTTP_OK, urlConn.getResponseCode());
    } catch (IOException e) {
    System.err.println("Error creating HTTP connection");
    e.printStackTrace();
    throw e;
    }
    }

    since i m going from 0 to 255, the whole process takes like an hour to finish, so I was wondering is there a way to check, which is faster than that?


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Testing whether a list of URLs are active or not in java?

    You could use a Socket with a timeout set.

    As explained here - java - can i speed up the scanning port process? - Stack Overflow

    Also see - http://www.antionline.com/showthread.php?t=255698
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. testing Java jsp/servlets
    By cgodfrey in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: March 30th, 2011, 03:44 PM
  2. Craating non active window ,and inputing to the non active window.
    By java-beginner in forum Java Theory & Questions
    Replies: 0
    Last Post: February 25th, 2011, 10:13 PM
  3. Parsing urls
    By Riddhi Sharma in forum Java Theory & Questions
    Replies: 2
    Last Post: January 25th, 2011, 10:06 AM
  4. Replies: 0
    Last Post: January 12th, 2011, 08:41 AM
  5. URLs in browsers
    By subhvi in forum Java Networking
    Replies: 3
    Last Post: October 8th, 2010, 03:06 AM

Tags for this Thread