This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes usage of stringbuffer length. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "usage of stringbuffer length." Watch "usage of stringbuffer length." New topic
Author

usage of stringbuffer length.

sowmya vasisht
Ranch Hand

Joined: Aug 23, 2001
Posts: 35
Hi,
Can anybody help me in knowing how to truncate Stringbuffer elements when it exceeds some predetermined legnth without loosing data.
first in a while loop of vector i m appending the account number, then the account status to a string buffer. but when the length of the string buffer exceeds a predetermined length, for eg., if the legnth has to be 400, then if the addition of accoutn number and status is more than 400 then it should remove the last added number and status. and pass the data which is less than 400 or equal to.
Could anybody tel me how to go about it??
thanx in advance.
sowmya
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi sowmya,
You can try something like this:

Hope this helps,
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: usage of stringbuffer length.
 
Similar Threads
IndexOutOfBoundsException thrown by java.nio bytebuffer.put(byte[] arsrc, int offset , int length)
Count no. of characters in xsl variable
Apache POI HSSF
inflating UTF-8 ant Latin-1 compressed text
OutOfMemory in an applet