www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.dwt - What's the equivalence of StringBuffer (in Java) in DWT or D?

reply Sam Hu <samhu.samhu gmail.com> writes:
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
Nov 20 2008
next sibling parent Brian <digitalmars brianguertin.com> writes:
string buf; // create a string
buf ~= "text"; // append some text
char c = buf[length-1]; // get the last char
Nov 20 2008
prev sibling parent Frank Benoit <keinfarbton googlemail.com> writes:
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.
Nov 20 2008