public synchronized void run() { byte[] buffer = new byte[BUFFER_SIZE]; for (; ; ) { try { this.wait(100); } catch (InterruptedException ie) { } int len = 0; try { int noBytes = pin.available(); if (noBytes > 0) { len = pin.read(buffer, 0, Math.min(noBytes, BUFFER_SIZE)); if (len > 0) { jTextArea.append(new String(buffer, 0, len)); jTextArea.setCaretPosition(jTextArea.getText().length()); } } } catch (IOException ioe) { throw new UIError("Unable to read from input stream! " + ioe.getMessage()); } } }