NXTCommOutputStream.java :  » UnTagged » lejos-pccomms-android » lejos » pc » comm » Android Open Source

Android Open Source » UnTagged » lejos pccomms android 
lejos pccomms android » lejos » pc » comm » NXTCommOutputStream.java
package lejos.pc.comm;

import java.io.*;

/**
 * Implementation of OutputStream over NXTComm using Bluetooth.
 */
public class NXTCommOutputStream extends OutputStream {
  private ByteArrayOutputStream baos;
  private NXTComm nxtComm;
  
  public NXTCommOutputStream(NXTComm nxtComm) {
    this.nxtComm = nxtComm;
    baos = new ByteArrayOutputStream();
  }
  
  public void write(int b) throws IOException {
    baos.write(b);
  }
  
  public void flush() throws IOException {
    byte[] b = baos.toByteArray();  
    nxtComm.write(b);
    baos.reset();
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.