troubleshooting Question

StringBuffer , StringWriter And Performance Problems

Avatar of sudhakar_koundinya
sudhakar_koundinya asked on
22 Comments1 Solution2135 ViewsLast Modified:
Hi have a situation where performance is a major issue

I am using jakarta POI package for reading WordDocument and writing the parsed text into output buffer.  By Default jakarta is providing writeAllText( as the method to write the parsed text into the output buffer.

But my client needs the method something like getDocumentText() that should written String. This return String will be used for some other purposes. SO I have used StringWriter as an Object to writeAllText() Method and using StringWriter().getBuffer().toString() I am  returning the parsed text as a String Object.

But this is becoming problem. Writing parsed text to Writer and then returning it into String slows down the proccess.

So what I did is I have written Some Other method in Jakata class that returns String. But Intenally uses StringBuffer

( I don't know whether it is legal or not to write my own method in Jakarta Package - If any body knows please let me know regarding this )

OK coming to my technical problem, even this is also not a quite good Idea, becase StringBuffer.toString() reduces the proformance.

And also you know that using of String for internal proccesses is not a quite good idea.(As it is Immutable). hence I have used StringBuffer for internal proccess.

So what is the best proccess I have to follow to make my return method works with high performance?


P.S : The return method should return String only.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 22 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 22 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros