Java network programming

hi,

Im building a network tool, where Im invoking the native methods in windows to get command prompt to "tracert <ip>".

I get an output like this,

Tracing route to [10.0.2.2]

over a maximum of 3 hops:

1<1 ms<1 ms<1 ms 192.168.1.1

2822 ms809 ms 1383 ms 220.247.232.7

3 1049 ms 1203 ms 1267 ms 10.0.2.2

Trace complete.

-

I saved this in a text file for manipulating the strings and get the "hop number" & the "IP". this result will go to a database.

ex: Hop No IP

1 192.168.1.1

2 220.247.232.7

you'll see this is a very very hard job, to filter out the hop No & IP from this file

Do you guys know any other good easy method to get this thing done. I'm kinda new to JAVA, so please help.

p.s I just saved this to a text file only for testing purposes, in the actual program I'll be gettig loads of results like this and saving all of them as a text file isnt the best option.. :)

Regards,

[1028 byte] By [AlienXa] at [2007-11-27 8:30:20]
# 1

> you'll see this is a very very hard job, to filter

> out the hop No & IP from this file

It looks like a very very easy job to me. You have lines, each with two tokens separated by a space. The first token is the hop number and the second number is the IP address.

See java.util.Scanner.

ejpa at 2007-7-12 20:20:54 > top of Java-index,Core,Core APIs...
# 2

im kinda lost... The string seems random.

It might be like the following..

1<some No of spaces>192.258.2.1

2<some No of spaces>*<some No of spaces>192.258.8.21

....

so how do I assign the first No which is the hop No & the last one which is the IP into two variables where they are seperated by some No of spaces or sometimes with a * in the middle.

Both of these are possible to exist in a given file.

Seems to work with a complex conditional test. but is there an easy way.

cheers

AlienXa at 2007-7-12 20:20:54 > top of Java-index,Core,Core APIs...
# 3
This looks to be a prime candidate for regular expressions. The various fields should be very easy to extract.P.S. I don't get the same format of output on my FC5 Linux as you get on what ever box you are running on.
sabre150a at 2007-7-12 20:20:54 > top of Java-index,Core,Core APIs...