Thread overview
What's the equivalence of StringBuffer (in Java) in DWT or D?
Nov 20, 2008
Sam Hu
Nov 20, 2008
Brian
Nov 20, 2008
Frank Benoit
November 20, 2008
Hello everybody!I was wondering what's the translation of StringBuffer in DWT or D,please refer to below codes in Java: //********************************************

FileDialog dlg=new FileDialog(shell,SWT.MULTI);
String fn=dlg.open();
if(fn!=null)
{
     StringBuffer buf=new StringBuffer();
     String[] files=dlg.getFileName();
     for(int i=0,n=files.length;i<n;i++)
     {
       buf.append(dlg.getFilterPath());
       if(buf.charAt(buf.length()-1) !=File.separatorChar)
       {
           buf.append(File.separatorChar);
       }
       buf.append(files[i]);
       buf.append("  ");
       }
       // other operation....
}
//*******************************************
Can anybody help to the same implement in DWT,Thanks so much!!
Sam
November 20, 2008
string buf; // create a string
buf ~= "text"; // append some text
char c = buf[length-1]; // get the last char
November 20, 2008
Sam Hu schrieb:
> Hello everybody!I was wondering what's the translation of StringBuffer in DWT or D,please refer to below codes in Java: //********************************************
> 
> FileDialog dlg=new FileDialog(shell,SWT.MULTI);
> String fn=dlg.open();
> if(fn!=null)
> {
>      StringBuffer buf=new StringBuffer();
>      String[] files=dlg.getFileName();
>      for(int i=0,n=files.length;i<n;i++)
>      {
>        buf.append(dlg.getFilterPath());
>        if(buf.charAt(buf.length()-1) !=File.separatorChar)
>        {
>            buf.append(File.separatorChar);
>        }
>        buf.append(files[i]);
>        buf.append("  ");
>        }
>        // other operation....
> }
> //*******************************************
> Can anybody help to the same implement in DWT,Thanks so much!!
> Sam

tango.text.Text has similar features, but a bit different API. I used it often for porting DWT. Unfortunately there is dwt.widgets.Text which might make symbol conflicts.