The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
March 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

StreamTokenizer and match location

Posted by Chris King on March 30, 2001 at 6:14 PM

Is there any way to find out WHERE precisely (that is, at what character index) a match occurred when using the StreamTokenizer class? Specifically, I'd like to be able to use that class for string extraction from source code, but I'd also like to be able to use the result to highlight the string in a text area that is displaying the code. Unfortunately, without a match location I have no way of synchronizing the location of the StreamTokenizer and the text area. I'd keep track of location manually during the scanning by adding up the match lengths, but StreamTokenizer discards whitespace without notifying you, so I can't even do that.
Is there any easy solution to this problem, or an alternate approach?
Thanks.



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us