Open URL strange problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fadhelbh
    New Member
    • Nov 2007
    • 2

    #1

    Open URL strange problem

    Guy,

    I'm trying to open a URL and the good news that I can open it then read the data line by line. the data changes every second so i have to read it in an infinite loop. By other words, load the URL then read it line by line, again and again.

    the problem the loop stops but no error msgs, memory is not full and there is nothing taking 100% of the CPU !

    The while loop code as follow:

    while(true){
    //the code to load the URL
    System.out.prin tln("Start");
    while(true){
    System.out.prin tln("Check 1");
    if((stringLine = myDataInputStre am.readLine()) == null) break;
    System.out.prin tln("Check 2");
    System.out.prin tln(stringLine) ;
    }
    System.out.prin tln("End");
    }

    After 3-4 hours of running the code print Check1 and stops, i does not terminate, just stops without giving any messages!

    It do print some of the URL data lines before this happens, it mean it loaded the URL but somehow the statement "(stringLin e = myDataInputStre am.readLine()) == null" does not return true neither false !

    what is going on !? Help guys

    And sorry for my grammar.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by fadhelbh
    Guy,

    I'm trying to open a URL and the good news that I can open it then read the data line by line. the data changes every second so i have to read it in an infinite loop. By other words, load the URL then read it line by line, again and again.

    the problem the loop stops but no error msgs, memory is not full and there is nothing taking 100% of the CPU !

    The while loop code as follow:

    while(true){
    //the code to load the URL
    System.out.prin tln("Start");
    while(true){
    System.out.prin tln("Check 1");
    if((stringLine = myDataInputStre am.readLine()) == null) break;
    System.out.prin tln("Check 2");
    System.out.prin tln(stringLine) ;
    }
    System.out.prin tln("End");
    }

    After 3-4 hours of running the code print Check1 and stops, i does not terminate, just stops without giving any messages!

    It do print some of the URL data lines before this happens, it mean it loaded the URL but somehow the statement "(stringLin e = myDataInputStre am.readLine()) == null" does not return true neither false !

    what is going on !? Help guys

    And sorry for my grammar.
    Why do you have two while loops? Are you reloading the URLs all the time? The code probably breaks out of the inner while when there is no data. Perhaps if you show the complete code you are using as it is ...

    Comment

    • fadhelbh
      New Member
      • Nov 2007
      • 2

      #3
      Thanks for your reply...

      If the code breaks out of the inner while when there is no data, the code should print "End"
      the code prints "Check 1" and get stuck !?
      it should either print "Check 2" or "End" but it don't !

      The code is too long as it login to secured website using username and password then using the given session to open another page.

      Anyway I will try to simplify the code and get back to you

      Comment

      Working...