| Author |
Get a single line from a String Buffer
|
Peter Shipway
Ranch Hand
Joined: Mar 25, 2004
Posts: 71
|
|
|
How do i get a single line from a string buffer that has already been created?
|
 |
Stefan Wagner
Ranch Hand
Joined: Jun 02, 2003
Posts: 1923
|
|
How do you know the Stringbuffer contains lines at all? If your buffer looks like this: text2 seems to be a line, but text1 and text3 could be a part of a line. For a buffer containing no NewLine at all, would you say the whole buffer is a line on it's own? So do we have three lines here?:
|
http://home.arcor.de/hirnstrom/bewerbung
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8265
|
|
You can read a line from a StringBuffer using Readers:
|
"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
|
 |
Mike Gershman
Ranch Hand
Joined: Mar 13, 2004
Posts: 1272
|
|
That gets you the first line. You may need to create the BufferedReader as shown and then call readLine() on it until you get the line you want.
|
Mike Gershman
SCJP 1.4, SCWCD in process
|
 |
 |
|
|
subject: Get a single line from a String Buffer
|
|
|