BluetoothInputStreampublic final class BluetoothInputStream extends InputStream BluetoothInputStream.
Used to write to a Bluetooth socket. |
Fields Summary |
---|
private BluetoothSocket | mSocket |
Methods Summary |
---|
public int | available()Return number of bytes available before this stream will block.
return mSocket.available();
| public void | close()
mSocket.close();
| public int | read()Reads a single byte from this stream and returns it as an integer in the
range from 0 to 255. Returns -1 if the end of the stream has been
reached. Blocks until one byte has been read, the end of the source
stream is detected or an exception is thrown.
byte b[] = new byte[1];
int ret = mSocket.read(b, 0, 1);
if (ret == 1) {
return (int)b[0] & 0xff;
} else {
return -1;
}
| public int | read(byte[] b, int offset, int length)Reads at most {@code length} bytes from this stream and stores them in
the byte array {@code b} starting at {@code offset}.
if (b == null) {
throw new NullPointerException("byte array is null");
}
if ((offset | length) < 0 || length > b.length - offset) {
throw new ArrayIndexOutOfBoundsException("invalid offset or length");
}
return mSocket.read(b, offset, length);
|
|