stringbuilder Questions

1

Solved

In scenarios where I am using 5-10 replacements is it necessary to use stringbuilder. String someData = "......"; someData = someData.replaceAll("(?s)<tag_one>.*?</tag_one>", ""); some...
Petal asked 22/12, 2017 at 10:32

5

Solved

I need a way to read all sections/keys of ini file in a StringBuilder variable: [DllImport("kernel32.dll")] private static extern int GetPrivateProfileString(string lpAppName, string lpKeyName, st...
Cordwood asked 17/8, 2011 at 8:48

1

Solved

While investigating a performance test result I found the following stack trace reported in Java Flight Recorder's "Hot Methods": Stack Trace Sample Count Percentage(%) ----------- ------------ --...
Merwyn asked 1/12, 2017 at 9:28

8

Solved

What is the default capacity of a StringBuilder? And when should (or shouldn't) the default be used?
Surrounding asked 29/10, 2008 at 9:23

1

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 In...
Johannesburg asked 4/10, 2017 at 21:25

2

Solved

In JDK 8, StringBuffer class has a toStringCache, while StringBuilder doesn't. /** * A cache of the last value returned by toString. Cleared * whenever the StringBuffer is modified. */ private ...
Karylkarylin asked 19/9, 2017 at 7:33

2

Solved

Is it true that StringBuilder is slower than concatenate a dozen of strings? How does compiler optimize the string concatenation so that joining a dozen of strings using "+" will be better than Str...
Vandavandal asked 11/9, 2017 at 8:44

2

Solved

I was trying to figure out when to use or why capacity() method is different from length() method of StringBuilder or StringBuffer classes. I have searched on Stack Overflow and managed to come up...
Notation asked 6/9, 2017 at 9:24

9

Solved

When doing concatenating lots of strings, I have been recommended to do it using a StringBuilder as such: StringBuilder someString = new StringBuilder("abc"); someString.append("def"); someString....
Glendon asked 11/2, 2011 at 4:3

8

Solved

Suppose our application have only one thread. and we are using StringBuffer then what is the problem? I mean if StringBuffer can handle multiple threads through synchronization, what is the proble...

4

Solved

Today I was reading Antonio's Blog about toString() performance and there is a paragraph: What used to be considered evil yesterday (“do not concatenate Strings with + !!!“), has become cool an...
Worry asked 24/5, 2017 at 4:58

3

Solved

To concatenate String we often use StringBuilder instead of String + String, but also we can do the same with String.format which returns the formatted string by given locale, format and arguments....
Piotrowski asked 22/5, 2017 at 16:24

3

Solved

When I have an empty StringBuilder with a capacity of 5 and I write "hello, world!" to it, does the C# standard specify the new capacity of the StringBuilder? I have a vague memory that it's twice ...
Neogene asked 25/9, 2011 at 18:59

13

Solved

What is the difference between string and StringBuilder? Also, what would be some examples for understanding?
Tallbot asked 18/6, 2010 at 12:9

5

Solved

I have the following code: StringBuilder data = new StringBuilder(); for (int i = 0; i < bytes1; i++) { data.Append("a"); } byte[] buffer = Encoding.ASCII.GetBytes(data); But I get this er...
Cleary asked 2/2, 2012 at 3:41

6

Solved

The following code sort of works, but fixes the number of elements in String[]. Is there a way to make a String[] add the number of elements needed dynamically? private static StringBuilder names ...
Bolection asked 12/8, 2010 at 21:33

6

Solved

Is there a way to append two string builders? And if so - does it perform better than appending a string to a StringBuilder ?
Affiant asked 23/6, 2011 at 13:0

8

Solved

I have a condition that a StringBuilder keeps storing lines matching a pattern from a large flat file (100's of MB). However after reaching a condition I write the content of the StringBuilder vari...
Incompressible asked 12/9, 2013 at 14:18

2

Solved

I have a StringBuffer initialized outside for loop and inside for loop I am concatenating some strings. I am getting the warning 'StringBuffer stringBuffer' may be declared as 'StringBuilder'...

4

Solved

I know that Javac compiler is able to transform String concatenation + using StringBuilder/StringBuffer, and I'm curious to know starting from which version this change was introduced? I'm using t...
Alessandraalessandria asked 27/2, 2017 at 14:15

2

Solved

I know that in more recent Java versions string concatenation String test = one + "two"+ three; Will get optimized to use a StringBuilder. However will a new StringBuilder be generated each tim...
Passionate asked 26/10, 2016 at 16:29

2

Solved

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(TA...
Medea asked 18/12, 2011 at 18:32

1

I have the following piece of code in Java. String foo = " "; Method 1: StringBuffer buf = new StringBuffer(); buf.append("Hello"); buf.append(foo); buf.append("World"); Method 2: StringB...
Dey asked 7/6, 2016 at 7:14

15

Solved

What is the difference between String and StringBuffer in Java? Is there a maximum size for String?
They asked 13/3, 2010 at 17:25

6

Solved

I'm trying to use stringbuilder to create a body of string to be used in a text (not HTML) email. However some lines (where i include dynamic data, a new line is not added, but in some the newline ...
Hogback asked 22/6, 2012 at 12:4

© 2022 - 2024 — McMap. All rights reserved.