Questions tagged [stringbuilder]

Stringbuilder is a class that provides a convenient and efficient way of working with text data in Java and .NET framework.

Stringbuilder is a class that provides a convenient and efficient way of working with text data. Implementation of the stringbuilder can be found in .NET framework and Java.

The very idea of the class is being a character array with the capability to insert and append new characters. It avoids copying the strings in the memory, hence improves the performance.

2114 questions
0
votes
0 answers

Unable to Get Output From While Loop in Javascript

I'm working on my final project of the Winter 2017 quarter to demonstrate how to use Regular Expressions in both C# and JavaScript code behind pages. I've got the C# version of my demonstration program done, but the JavaScript version is making me…
JBM
  • 63
  • 1
  • 2
  • 12
0
votes
0 answers

Why StringBuilder gives better performance than StringBuffer?

My question is that many documentation over mutable strings, I have read that StringBuilder gives faster result as compare to StringBuffer. People gives reason that, StringBuilder is not synchronized and StringBuffer is synchronized, but it gives…
Vatsal Jagani
  • 83
  • 1
  • 8
0
votes
0 answers

C# and StringBuilder. I am new to C#. I could not understand the output

using System; using System.Text; namespace Objects { class Program { static void Main(string[] args) { StringBuilder x = new StringBuilder(), y = x; x.Append("Hello, "); …
0
votes
2 answers

Replace substring in stringbuilder, don't know location of substring

Example: If the display name contains "Lambda (?)" then replace with "Lambda (λ"). I have four various substrings that I'm trying to replace Here's the part of my stringbuilder code: sb.Append("
Andy Jr.
  • 95
  • 1
  • 10
0
votes
0 answers

How to send Chart Control in email using C# ASP.Net

I have written the below code to send the Gridview and Chart Image in email body message (not as an attachment) using C# ASP.Net. StringBuilder sb = new StringBuilder(); string MailSturcture; using (System.IO.StringWriter sw = new…
Arun
  • 728
  • 4
  • 16
  • 30
0
votes
2 answers

How to fix out of bounds index error?

FIXED: I removed my while loop and added if (num.contains(count) == true) { freq = Collections.frequency(num, count); for (int k = 0; k < freq; k++) { sb.append(temp); } …
Yawn
  • 173
  • 3
  • 20
0
votes
1 answer

After I split a string, how would I modify each word independently? - Java

For example, if I have a string called 'S', split it using .split and store all the words in String[] arr = s.split(" "), how would I modify each word? Let's say I want to remove the first letter and add into the end, then insert some more…
JTurner
  • 1
  • 1
0
votes
0 answers

Mixing String + operator with StringBuilder

Let's say I have the following code: String RET = System.getProperty("line.separator"); int x = 5, y = 3; StringBuilder sb = new StringBuilder(); sb.append("Ship located at " + x + ", " + y + RET); sb.append("Current time: " +…
piegames
  • 975
  • 12
  • 31
0
votes
2 answers

How to write Unified code for StringBuffer and StringBuilder in java 6

I have the following code that is duplicated and I'd like to only write it once (please note that it's just a sample of what I want to achieve): public class A { public void doSomething(StringBuffer additional, int start, int end) { try…
Dana G
  • 64
  • 1
  • 6
0
votes
1 answer

JLabel set as text list items

I have a list that contains Strings and I am trying to set its items as JLabel text, the only problem is that the result is a single line JButton btnSearch = new JButton("Search"); btnSearch.addMouseListener(new MouseAdapter() { @Override …
alin dradici
  • 201
  • 2
  • 4
  • 11
0
votes
2 answers

Using stringBuilder in combination with String.format

I have an alert dialog that works fine, but I suspect I can clean up my code some. I'm using a stringBuilder to help pull together the message, in addition to using String.format to get the spacing pleasant for each line. It's the String.format…
seekingStillness
  • 4,833
  • 5
  • 38
  • 68
0
votes
1 answer

Add multiple values of string to string array

I have a program where i am calling a method which reads xls file and fetches 2nd column. public static String readExcel(String FileName) throws BiffException, IOException, java.text.ParseException, InterruptedException { String ss…
0
votes
1 answer

Unity EditorGUIUtility.systemCopyBuffer, StringBuilder append string that contains newline characters

I want to use a StringBuilder to merge a couple of strings, and then give them to EditorGUIUtility.systemCopyBuffer in UnityEngine. One of the strings contains newline characters in itself, but they are not present when I paste the contents of the…
Helena
  • 1,041
  • 2
  • 12
  • 24
0
votes
1 answer

Cannot past StringBuilder to another activity

I want make application to get json from server, and set it into text view, but its always shown null pointer try { Response response = client.newCall(request).execute(); if(!response.isSuccessful()){ throw…
Denny Kurniawan
  • 168
  • 1
  • 3
  • 21
0
votes
1 answer

Getting all positions of an occuring String using StringBuilder.indexOf()

Java Beginner over here. I'm currently working on a programm that searches a part of the human DNA. Specifically, I want to find all occurences of a String within a StingBuilder, using StringBuilder.indexOf(). But I need all occurences, not just the…
Smunfr
  • 15
  • 5