java - StreamTokenizer.nextToken skipping too many tokens? -


I have the following code that should go through each token, and when it appears in the specified character sequence it means that A comment is either starting or ending

I made the last statement to execute some code if the position is not between the comments.

  int commentFound = -1; Commented int commented = -1; Do {int token = st.nextToken (); Switch (token) {case streamTrokenizer. TT_EOF: System.out.println ("The file ended."); Eof = true; Default: if ((token == '& lt;')) {System.out.println (st.sval); If (st.nextToken () == '!') {System.out.println (st.sval); If (st.nextToken () == '-') {if (st.nextToken () == '-') {if (st.nextToken () == '-') {System.out.println ("Comment Found on line number: "+ st.lineno ()); Commentfoot = st.lineno (); }} And if ((token == '-')) {if (st.nextToken () == '-') {if (st.nextToken () == '-') {if (st NextToken () == '& gt;') {System.out.println ("Comment ended:" + st.lineno ()); Comment Comment = st.lineno (); }}}} If ((Comment!! -1 =) & amp; ((St. Linenno (>> Comment) & amp; amp; (St.Lilino) commented comment)) { / Code>  

The beginning tag of the comment is always found, however the closing tag is not always found. After some debugging I feel that I have come to know that 'next talk' is leaving too many tokens Is it possible? And if so, can there be any way to fix this problem?

Any help would be greatly appreciated

It seems that you have There is a bug in detecting tokens. You need to provide source text. Your code is currently in this cccc --- & gt; Like does not recognize the end because it gives cccc as a full word token.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -