home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / samples.z / TextBoxOutputStream.java < prev    next >
Text File  |  1996-12-09  |  886b  |  36 lines

  1. import java.io.OutputStream;
  2. import powersoft.jcm.ui.TextBox;
  3.  
  4. public class TextBoxOutputStream extends OutputStream
  5. {
  6.     public TextBoxOutputStream( TextBox box )    
  7.     {
  8.         _box = box;
  9.     }
  10.  
  11.     public void write( byte b[] )
  12.     {
  13.         StringBuffer buf = new StringBuffer(b.length);
  14.         for( int i = 0; i < b.length; i++ ) {
  15.             buf.append( (char)b[i] );
  16.         }
  17.         _box.setText( _box.getText() + buf.toString() );
  18.     }
  19.     
  20.     public void write( byte b[], int off, int len )
  21.     {
  22.         StringBuffer buf = new StringBuffer(len);
  23.         for( int i = 0; i < len; i++ ) {
  24.             buf.append( (char) b[ off + i ] );
  25.         }
  26.         _box.setText( _box.getText() + buf.toString() );
  27.     }
  28.  
  29.     public void write( int b )
  30.     {
  31.         _box.setText( _box.getText() + (char)b );
  32.     }
  33.  
  34.     private TextBox _box;
  35. }
  36.