Returns a number between 0 and 255 for the next byte that's waiting in the buffer. Returns -1 if there is no byte, although this should be avoided by first checking available() to see if any data is available. @webref client @usage application @webBrief Returns a value from the buffer
()
| 375 | * @webBrief Returns a value from the buffer |
| 376 | */ |
| 377 | public int read() { |
| 378 | synchronized (bufferLock) { |
| 379 | if (bufferIndex == bufferLast) return -1; |
| 380 | |
| 381 | int outgoing = buffer[bufferIndex++] & 0xff; |
| 382 | if (bufferIndex == bufferLast) { // rewind |
| 383 | bufferIndex = 0; |
| 384 | bufferLast = 0; |
| 385 | } |
| 386 | return outgoing; |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | |
| 391 | /** |