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
4 answers

Is it possible to set an exact number of characters for an input using StringBuilder?

I'd like to be able to force a 10 character input using StringBuilder. I know it can be set to a max char limit but can I make it exactly 10? Maybe something like this: import java.util.Scanner; public class Phonenumber { public static void…
0
votes
2 answers

Which comes first? The char or the String?

Most of the examples I find in my search for the answer are embedded in complex code. I'm just trying to have a question program know to accept either upper or lower case responses to a two-answer (binary?) question and then to use either answer to…
0
votes
2 answers

Excel not opening .xls made from C# StringBuilder

The following code was written several months ago and tested perfectly, with that funny little warning message in Excel. Now, though, after the C# code runs without errors and the browser downloads the exported .xls file, the Excel application…
jle
  • 269
  • 8
  • 25
0
votes
3 answers

how to count how many times each word appears?

I'm trying to count how many times each word from uniqueBagOfWords appears in each sentence from the 'sentences' arraylist. uniqueBagOFwords = [i, like, to, play, tennis, think, football, needs, big, changes] I would like to be able to count how…
T.newGuy1620
  • 15
  • 1
  • 1
  • 6
0
votes
2 answers

How to append style definition to tag within string using StringBuilder?

I'm building a HTML table from a C# typed list. So far building the table works fine, but I now need to append a style to one of the tags within the string that builds the table. What I have tried is simply adding the style definition to the TD…
Brian Var
  • 6,029
  • 25
  • 114
  • 212
0
votes
2 answers

Implementing a specific font in Email in an asp.net mvc application

I want to set a specific font(helvetica neue) for the Email Content, which will be fired due to any user opertaion. It is not the base font i am using, and the email content is generated by StringBuilder. Looking forward for suggestions Thanks &…
user5710892
0
votes
1 answer

Batch-file string builder

I want to create a string builder to combine the line contents of a .txt-file by using a batch file so I can import it later on(CSV). The source file contains lines of information that repeat themselves after for example 3 times. Like this: Info1…
Nero
  • 37
  • 1
  • 5
0
votes
1 answer

vb.net stringbuilder double quote

I've been using stringbuilder for a long time and have never had this come up before. In this case I'm using a stringbuilder to put together a lengthy XML chunk, then at the end it gets put into a string to get submitted to a web service. At the…
0
votes
4 answers

Chained string replace in .NET

Given: a base64 string When: Foo is called Then: Foo returns the input string with the following character replacements ('A' => '_', 'B' => '-', 'C' => '+') and does it as fast as possible I compared several algorithms to determine which version of…
mo5470
  • 937
  • 3
  • 10
  • 26
0
votes
2 answers

string builder vs string

Possible Duplicates: When to use StringBuilder? string is immutable and stringbuilder is mutable what is diffrent of string and string builder ? where do we use string builder ?
fariba
  • 665
  • 1
  • 8
  • 7
0
votes
0 answers

Unable to append a string to StringBuilder array element

Please refer to the following code: Scanner scan = new Scanner(System.in); int T = Integer.parseInt(scan.nextLine()); StringBuilder []str = new StringBuilder[T]; String temp = new String(); for (int i=0; i < T; i++){ …
0
votes
0 answers

Strange behaviour of StringBuilder and OutOfMemory Errors

i have task - need to get all combinations of elements in multi-dimensional, different size list`s. When i put sb initialize in (1) place - i have Error: "Exception in thread "main" java.lang.OutOfMemoryError: Java heap space" when i put it in (2) -…
0
votes
0 answers

Java == comparison on StringBuilder

Why this code doesn't compile on line 7? public class HelloWorld { public static void main(String[] args) { String s1 = "java"; StringBuilder s2 = new StringBuilder(); if (s1 == s2) System.out.print("1"); } } and why this is…
frank86ba
  • 23
  • 6
0
votes
3 answers

String builder and String Concat

I have a piece of code that look follows this pattern , var stringBuilder =new StringBuilder( string.Concat(" string", _variable, "another string" , _variable2 ... ); according to some logic do stringBuilder.Append(" Some more strings"); I…
Shachaf.Gortler
  • 5,655
  • 14
  • 43
  • 71
0
votes
1 answer

String index out of range: 0

While looking for a solution to this I found a suggestion to use sc.next() instead of sc.nextLine() but I can't use that so I require additional assistance. I Am developing an online multiplayer text game and need to filter player name but I keep…
1 2 3
99
100