File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Get a single line from a String Buffer Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Get a single line from a String Buffer" Watch "Get a single line from a String Buffer" New topic
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Get a single line from a String Buffer
 
Similar Threads
java.net.URLConnection example?
An exception in java-XML --kindly clarify-urgent
Pls Help on read the log file BACKWARd?
OutOfMemoryError: Java heap space error when exporting more than 65MB file
why it is giving errors