TYPE=WIFI|TIME=1263867778390|ID=00:24:c3:31:2b:e0|NAME=csusm|RSSI=-93|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867778390|ID=00:12:17:7b:33:04|NAME=csusm|RSSI=-80|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867778390|ID=00:1f:27:55:f7:70|NAME=USMHotspot|RSSI=-70|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867778390|ID=00:1e:13:ee:3e:40|NAME=USMHotspot|RSSI=-85|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867778390|ID=00:24:c3:31:b8:80|NAME=csusm|RSSI=-91|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867778390|ID=00:90:4c:60:04:02|NAME=csusm|RSSI=-94|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867778390|ID=00:1b:0d:d6:6d:50|NAME=USMHotspot|RSSI=-70|WEP=true|INFR=true

The above is a part of my log file.
The problem i faced is how to just get ID with its particular RSSI value ?
Because i want to calculate the average RSSI value for each different ID .
I tried split.string, delimiter, regular expression but i became blur after this. I don know what is the best way to do this !
Im new in Java, so kindly help me.... Thank .!

Both the String class's split method and regular expressions would be good solutions for this problem. Using the split method and splitting on "[|]" would probably be easier though. The reason you would have to split on [|] and not on | is as follows: (quoted from s.o.s's post in another thread):

| has a special meaning when it comes to regular expressions, it's called the alternation symbol.

If you have something like "##|##|##".split("|") , it's the same as "##|##|##".split("") since a single pipe symbol is the same as saying "alternate between a blank string and another blank string" which is the same as a blank string.

You can either:

  • Escape this pipe character and tell the regex engine to treat is at a literal pipe character. Something like "string".split("\\|")
  • Use character classes, similar to the example posted above (i.e. [|] )

Anyway, I'm assuming that before you did that, you would read each line of text into a separate String using Scanner's nextLine() method, so that split([|]) would give you an array of 7 elements per line. Then you could simply tell it to give you array[2] (your ID number) and array[4] (the corresponding RSSI)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.