This is suppose to be fast as the previous one was creating a new string
every time u called +=.

On Sun, 2003-01-19 at 23:33, Allan Wick wrote:
> 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-----
> From: Roger Lacroix [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, January 19, 2003 5:20 PM
> To: JDJList
> Subject: [jdjlist] Slow: string += string
> 
> 
> All:
> 
> 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
> ____________________________________________________ 
-- 
" In times of profound change, the learners inherit the earth, while the
learned find themselves beautifully equipped to deal with a world that
no longer exists ." Al Rogers


____________________________________________________
To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm

Be respectful! Clean up your posts before replying
____________________________________________________

Reply via email to