FileDocCategorySizeDatePackage
BluetoothOutputStream.javaAPI DocAndroid 5.1 API3190Thu Mar 12 22:22:10 GMT 2015android.bluetooth

BluetoothOutputStream

public final class BluetoothOutputStream extends OutputStream
BluetoothOutputStream. Used to read from a Bluetooth socket.
hide

Fields Summary
private BluetoothSocket
mSocket
Constructors Summary
BluetoothOutputStream(BluetoothSocket s)

        mSocket = s;
    
Methods Summary
public voidclose()
Close this output stream and the socket associated with it.

        mSocket.close();
    
public voidflush()
Wait until the data in sending queue is emptied. A polling version for flush implementation. Use it to ensure the writing data afterwards will be packed in the new RFCOMM frame.

throws
IOException if an i/o error occurs.
since
Android 4.2.3

        mSocket.flush();
    
public voidwrite(int oneByte)
Writes a single byte to this stream. Only the least significant byte of the integer {@code oneByte} is written to the stream.

param
oneByte the byte to be written.
throws
IOException if an error occurs while writing to this stream.
since
Android 1.0

        byte b[] = new byte[1];
        b[0] = (byte)oneByte;
        mSocket.write(b, 0, 1);
    
public voidwrite(byte[] b, int offset, int count)
Writes {@code count} bytes from the byte array {@code buffer} starting at position {@code offset} to this stream.

param
b the buffer to be written.
param
offset the start position in {@code buffer} from where to get bytes.
param
count the number of bytes from {@code buffer} to write to this stream.
throws
IOException if an error occurs while writing to this stream.
throws
IndexOutOfBoundsException if {@code offset < 0} or {@code count < 0}, or if {@code offset + count} is bigger than the length of {@code buffer}.
since
Android 1.0

        if (b == null) {
            throw new NullPointerException("buffer is null");
        }
        if ((offset | count) < 0 || count > b.length - offset) {
            throw new IndexOutOfBoundsException("invalid offset or length");
        }
        mSocket.write(b, offset, count);