private void sendData(FileInputStream data) throws SerialConnectionException {
    int tosend = 0;
    byte[] databuff = new byte[_chunkSize];

    _sent = 0;
    try {
      tosend = data.read(databuff);
      while (tosend != -1) {
        if (!_keepRunning) return;
        _os.write(databuff, 0, tosend);
        _savedStream.write(databuff, 0, tosend);
        _sent += tosend;
        // update GUI
        _results.updateBytesSent(_sent);
        tosend = data.read(databuff);
      }
    } catch (IOException e) {
      throw new SerialConnectionException("Error writing to i/o streams");
    }
  }
 /**
  * close the output io stream associated with the send comm port.
  *
  * @throws IOException
  */
 public void closeio() throws IOException {
   if (_os != null) _os.close();
   if (_fdata != null) _fdata.close();
 }