I'm getting a java outOfMemoryError when I call this method - i'm using it in a loop to parse many large files in sequence. my guess is that result.toString() is not getting garbage collected properly during the loop. if so, how should i fix it?
private String matchHelper(String buffer, String regex, String method){
Pattern abbrev_p...
I'm interested to hear from other developers their opinion on an approach that I typically take. I have a web application, asp.net 2.0, c#.
What I usually do to write out drop downs, tables, input controls, etc. is in the code behind use StringBuilder and write out something like sb.Append("
I don't find myself using to many .net cont...
I am reading a csv file that has about 50,000 lines and 1.1MiB in size (and can grow larger).
In Code1, I use String to process the csv, while in Code2 I use StringBuilder (only one thread executes the code, so no concurrency issues)
Using StringBuilder makes the code a little bit harder to read that using normal String class.
Am I p...
It feels dirty. But maybe it isn't... is it ok to use a StringBuilder for writing XML? My gut instinct says "although this feels wrong, it's probably pretty darn performant because it's not loading extra libraries and overhead it's not doing whatever extra method calls XmlWriter invokes." It also seems like it's just less code in general...
I have written a program for a stack. (http://stackoverflow.com/questions/2617367?tab=votes#tab-top)
For this i needed a StringBuilder to be able to show me what was in the stack else i would get the class name instead of the actual values inside.
My question is there any other way except for a StringBuilder for such kind of problem?
Al...
How do you append new line(\n\r) character in StringBuilder?
...
I have this function. The visual studio profile marked the line with string.Format as hot and were i spend much of my time.
How can i write this loop more efficiently?
public string EscapeNoPredicate(string sz)
{
var s = new StringBuilder(sz);
s.Replace(sepStr, sepStr + sepStr);
foreach (char v in Illeg...
The situation is that I am making a WCF call to a remote server which is returns an XML document as a string.
Most of the time this return value is a few K, sometimes a few dozen K, very occasionally a few hundred K, but very rarely it could be several megabytes (first problem is that there is no way for me to know).
It's these rare ...
This might be a bit of a code smell, but I have seen it is some production code, namely the use of StringBuilder as opposed to XmlDocument when creating XML documents. In some cases these are write once operations (e.g. create the document and save it to disk) where as others are passing the built string to an XmlDocument to preform an X...
I am trying to write a hello world type program for using virtual channels in the windows terminal services client.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
IntPtr mHandle = IntPtr.Zero;
private void Form1_Load(object sender, EventArgs e)
{
mHandle = NativeMet...
I have a DataReader and a StringBuilder (C#.NET) used in the following way;
while (reader.Read())
{
sb.AppendFormat("{0},{1},{2},",reader["Col1"], reader["Col2"], reader["Col3"]);
}
Which works great for my use, but when a row is null I need it to return "null", inste...
It's common knowledge that you shouldn't use a StringBuilder in place of a small number of concatenations:
string s = "Hello";
if (greetingWorld)
{
s += " World";
}
s += "!";
However, in loops of a significant size, StringBuilder is the obvious choice:
string s = "";
foreach (var i in Enumerable.Range(1,5000))
{
s += i.ToStr...
I'm using VB's StringBuilder, and I was curious what is considered "best practice" for emptying the builder/setting it to a new string. Would it be something like this:
Dim str As New System.Text.StringBuilder()
str.Append("Some string to remove")
str = new System.Text.StringBuilder()
str.Append("Ahh, fresh new text!")
or is there a "...
in a C# file i have a
class Archiver {
[DllImport("Archiver.dll")]
public static extern void archive(string data, StringBuilder response);
}
string data is an input, and StringBuilder response is where the function writes something
the archive function prototype (written in C) looks like this:
void archive(char * dataChr, ch...
My C# (.NET 2.0) application has a StringBuilder variable with a capacity of 2.5MB. Obviously, I do not want to copy such a large buffer to a larger buffer space every time it fills. By that point, there is so much data in the buffer anyways, removing the older data is a viable option. Can anyone see any obvious problems with how I'm ...
I have this code to concate some array elements:
StringBuilder sb = new StringBuilder();
private RatedMessage joinMessage(int step, boolean isresult) {
sb.delete(0, sb.length());
RatedMessage rm;
for (int i = 0; i <= step; i++) {
if (mStack[i] == null)
continue;
rm = mStack...
Am trying to create a well-optimised bit of code to create number of X-digits in length (where X is read from a runtime properties file), based on a DB-generated sequence number (Y), which is then used a folder-name when saving a file.
I've come up with three ideas so far, the fastest of which is the last one, but I'd appreciate any adv...
what's the difference in using tag builder and string builder to create a table in a htmlhelper class, or using the HtmlTable?
aren't they generating the same thing??
...
Guys, help me clarify.
Say i have the following line in my program:
jobSetupErrors.append("abc");
In the case above where jobSetupErrors is a StringBuilder(), what i see happen is:
New String Object is created and assigned value "abc"
value of that String object is assigned to the existing StringBuilder object
If that is correct,...
I'd like to know the difference between string and StringBuilder and also need some examples for understanding.
...