String concatenation into StringBuilder java

2011-03-25T16:37:08

I have a legacy Java file which uses String concatenation to build huge String objects.Its a serious performance issue.Is there a method as such which does the following

String test="I am a very bad programmer"
+"to use concatenation"
+"Instead of StringBuilder"
+" or StringBuffer";

to

StringBuilder strBuilder= new StringBuilder();
strBuilder.append("I am a bad programmer");
strBuilder.append("to use concatenation");
strBuilder.append("Instead of StringBuilder");
strBuilder.append(" or StringBuffer");
String str= strBuilder.toString();

basically I need a stub in java just to give a the String instantiation as input and convert into StringBuilder.Anybody tried this in the past?

Copyright License:
Author:「Harish」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/5430168/string-concatenation-into-stringbuilder-java

About “String concatenation into StringBuilder java” questions

I have a legacy Java file which uses String concatenation to build huge String objects.Its a serious performance issue.Is there a method as such which does the following String test="I am a very bad
I saw this question and some similar and I think it's not duplicate : StringBuilder vs String concatenation in toString() in Java Here is the deal, I hear a very clever work colleague of mine tal...
For the following code, how would I use concatenation instead of StringBuilder to create the string in the following method? My teacher said to use concatenation and not StringBuilder. private sta...
I was looking at the String Javadoc when I noticed this bit about String concatenation: The Java language provides special support for the string concatenation operator ( + ), and for conversi...
My method below needs to return a String concatenated from strings. StringBuilder sb = new StringBuilder(); sb.append("count: ").append(this.count()).append( "\n"); return sb.toString(); In Int...
In Java, it's a common best practice to do string concatenation with StringBuilder due to the poor performance of appending strings using the + operator. Is the same practice recommended for Scala ...
According to Netbeans hint named Use chain of .append methods instead of string concatenation Looks for string concatenation in the parameter of an invocation of the append method of StringBuild...
Is it from a sight of resources reasonable to use a StringBuilder already to concat two strings or is there a minimum concatenation operations that makes the StringBuilder efficient?
I have some code like this: StringBuilder rgba = new StringBuilder(); for (...){ .... rgba.append(value + ", "); } IntelliJ shows me the following warning: string concatenation as argu...
I was reading this documentation page, http://developer.android.com/reference/android/util/Log.html. The section here caught my eye: Tip: Don't forget that when you make a call like Log.v(...

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.