Could you send me an example of StringBuffer pooling ?
I am not quite sure what you mean.
On Tue, 31 Jul 2001 05:39:55 -0700, Gokul Singh <[EMAIL PROTECTED]> wrote:
>On Tue, 31 Jul 2001 05:13:02 -0700, John Zink <[EMAIL PROTECTED]> wrote:
>
>[snipped]
>
>> int bytesRead;
>> StringBuffer buffer = new StringBuffer();
>> BufferedReader br = request.getReader();
>> while (( bytesRead = br.read()) != -1 )
>> buffer.append((char)bytesRead);
>> String newString = buffer.toString();
>>
>
>One thing that you know before hand is the length of the data that you are going to
>read. This is conveyed as part of the header Content-Length.
>You can get this value by using the method getContentLength() and use it to create
>the StringBuffer for the appropriate length(I am assuming presence of single byte
>characters only). This may save you quite a number of reallocation of the char array
>inside the StringBuffer.
>
>Also you can read the data from the stream in chunks by using the method read(char[],
>int off, int len) rather than reading each character. It is generally more efficient
>to read in chunks rather than making individual calls. In this case it also involves
>costly round cycle of upcasting and downcasting for each character which can be
>avoided.
>
>Also if the load is real heavy, you may plan to do pooling for the StringBuffers but
>I am not sure if that will help.
>
>Regds,
>Gokul
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html