• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

Java real-time (9600 baud) stream parsing

Hello,

I have a stream of data going by and I need to pull out some of the records. The stream is all ASCII.
The stream/record fields are delimited by slash "/".
My particular record is 256 chars and begins by a field of 6 BLANKS followed by a slash "/"
and 30 slashes "/" into the record I have an Identifier of /GH/. I then have 5 more fields delimited by "/", which marks the end of the record. There is other stuff in this stream which is useless and may, coincedentally have the same 30 s;ashes but it wil nothave the /BF/ identifier. Once I have found the target string I have to save the string from the frist 6 BLANKS to the last 5 fields.

Interesting problem....
I have loooked at split, tokenizer, etc and have found those solutions wanting because of the unusual
regex required. For example the following does not work as a recognizer:

1. Pattern p = Pattern.compile("[\\s\\s\\s\\s\\s\\s]/{30}/GH/{5}");

Thank You




0
dennisk1718
Asked:
dennisk1718
  • 2
1 Solution
 
ahoffmannCommented:
you cannot match to a stream, you need at least read the stream 'til you identified something you want to match, then you can use a regex against the stored (rad) data not the stream
0
 
dennisk1718Author Commented:
HUH,

Oh, ok...

Sure...I have a continous stream of data running by, and I need to grab some messages form that stream. I have only one chance and then it is gone. 9600bps is not too fast but...
I need a recognizer and a parser. I am stuck a little on the recognizer. I am using socket with readline currently, but it looks like I need to use a StringReader.

Are the Java I/O experts out there????

Thank You
0
 
ahoffmannCommented:
if you need to match something in real time in the stream, I guess you need to write your own parser
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now