Discussions

Web tier: servlets, JSP, Web frameworks: java question, tokenizer

  1. java question, tokenizer (1 messages)

    [javacode]
    while ((line = in.readLine()) != null) {
                    System.out.println(line);
                }
    [/javacode]

    if the IP address exists, the output is :

    Pinging 161.194.65.64 with 32 bytes of data:

    Reply from 161.194.65.64: bytes=32 time=16ms TTL=122
    Reply from 161.194.65.64: bytes=32 time<10ms TTL=122
    Reply from 161.194.65.64: bytes=32 time=16ms TTL=122
    Reply from 161.194.65.64: bytes=32 time<10ms TTL=122

    if the IP address does not exist , output is :

    Pinging 155.108.1.2 with 32 bytes of data:

    Request timed out.
    Request timed out.
    Request timed out.
    Request timed out.

    How to tokenize the variabel line to find out if it has four times the string "Request timed out."

    thanks, your help is appreciated
  2. java question, tokenizer[ Go to top ]

    Ehhh? This is a very basic java question.

    Just do a simple substring compare for "timeout" (or
    any other unique part of the timout reply)
    and if it find 4 of them all 4 pings failed.
    It exist a basic function to find out if a substring
    is part of a string.

    Using a Stringtokenizer for this job is overkill - unless you want to parse the data in a more complex way.