Use a
StringBuffer.
StringBuffer theBuffer = StringBuffer();
for
(int r = 0; r < selected.length;
r++)
{
{
theBuffer.append( rowdata[r] );
}
String
output = theBuffer.toString();
Something like that...
-Al
Wick
____________________________________________________-----Original Message-----All:
From: Roger Lacroix [mailto:[EMAIL PROTECTED]]
Sent: Sunday, January 19, 2003 5:20 PM
To: JDJList
Subject: [jdjlist] Slow: string += string
I have my cells of a table defined as Object[][]. In my program, I added the ability for the user to select rows of the table to copy to the system clipboard (i.e. copy / cut / paste functionality).
Depending on what the user is viewing, there could be 400 rows by 2000 columns.
i.e. Object[][] xx = new Object[400][2000];
Say the user selects 20 rows, then I need to combine 40000 cells (20 * 2000). I have done every trick that I can think of, but it still is not as fast as I would expect. Right now I combine each row into a string then I combine each row-string each the final string.
Here is my current code:
String[] rowData = new String[selected.length];
for (int r = 0; r < selected.length; r++)
{
ptr = selected[r];
rowData[r] = msgCells[ptr][1].toString();
for(int c = 2; c < endColumn; c++)
{
if (msgCells[ptr][c] != null)
{
rowData[r] += msgCells[ptr][c].toString();
}
}
}
for (int r = 0; r < selected.length; r++)
{
tempClipboard += rowData[r];
}
Does anyone out there in Java land have a tip / trick /snippet of code to quickly & efficiently combine a large number of objects into a SINGLE string.
Thanks to all.
later
Roger Lacroix
Enterprise Architect
Capitalware Inc.
____________________________________________________
To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm
Be respectful! Clean up your posts before replying
____________________________________________________
To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm
Be respectful! Clean up your posts before replying
____________________________________________________
