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
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.