| Author |
Process Text from JTextArea
|
celine mcgowan
Ranch Hand
Joined: Nov 22, 2003
Posts: 36
|
|
Hi Everyone, I wonder if someone could help me. I'm writing a 'mini-parser' in java for assembly code. Basically, i have a JTextArea where the asm goes. I need to know how to deal with the text from my textArea one line at a time? I can say: textArea.getText, but this returns all the text. Or i can say getLineStartOffset, getLineEndOffset which gives me one line (usually the first one). But, how do i get the first line via start & end offsets and then move on to the next line and so on until all lines of text are dealt with? Thanks a million, Celine
|
We've heard that a million monkeys at a million keyboards would eventually reproduce the entire works of Shakespeare. Now, thanks to the Internet, we know this is not true.<br />- Robert Wilensky
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8263
|
|
|
You can use a java.io.StringReader to read from a String object as if it were ai input stream, then wrap it with a BufferedReader which has a readLine() method. There's other helpful classes like PushbackReader, which allows you to put characters back into the stream you read them from and LineNumberReader, which keeps track of line numbers, which I imagine could be useful when writing a parser.
|
"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
|
 |
celine mcgowan
Ranch Hand
Joined: Nov 22, 2003
Posts: 36
|
|
That's great Joe. Thanks a million for your help. Celine
|
 |
 |
|
|
subject: Process Text from JTextArea
|
|
|