• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help on java string reading  RSS feed

 
ravindranath netha
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hava a String as follows:

.validate irc, irclink, irctxt {
.require s;
.macro irreg = '(\([1-9][0-9]*\)(\([A-Z]\)(\([ivx]+\)(\([IVX]+\))?)?)?)?';
.switch s {

.case '[1-9][0-9]*([A-Z][-][0-9]{1,3}|[A-Z])?(\([a-z]\)(\([1-9][0-9]*\)(\([A-Z]\)(\([ivx]+\)(\([IVX]+\))?)?)?)?)?'
{ /* ok */ }

.case '45K\([a]\)\([2]\)\([i][i]?\)'
{ /* ok */ }

.case '54([A-Z][-][0-9]{1,3}|[A-Z][A-Z]?)?(\([a-z]\)(\([1-9][0-9]*\)(\([A-Z]\)(\([ivx]+\)(\([IVX]+\))?)?)?)?)?'
{ /* ok */ }

.case '6720\([0-9]\)(\([A-Z]\))?'
{ /* ok */ }

.case '6724(\([a-z]\)(\([1-9][0-9]*\)(\([A-Z][A-Z]?\)(\([ivx]+\)(\([IVX]+\))?)?)?)?)?'
{ /* ok */ }

// end of
}

}

Now i want to pullout the string present in .switch{}. I am reading this whole string as line by line using Bufferedreader , but am not able to read the whole string present in .switch{}. Could any one advise me on this .Thanks!
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read a line at a time until you find the one starting with ".switch" and add this last line to a StringBuilder. Continue reading lines adding them to the StringBuilder until you reach the '}' that represents the end of the switch. Close the file.
 
ravindranath netha
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For .case also i have } , when it match } in .case line it will add . I can not depend on }.
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ravindranath netha wrote:For .case also i have } , when it match } in .case line it will add . I can not depend on }.


OK - then keep a count incrementing every time you find a '{' and decrementing every time you find a '}. When the count is zero you have the complete 'switch'.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!