Code example for UsbDeviceConnection

Methods: bulkTransfer

    public int read(byte[] dest, int timeoutMillis) throws IOException {
        int readAmt = Math.min(dest.length, mReadBuffer.length);
        readAmt = Math.min(readAmt, mReadEndpoint.getMaxPacketSize());
        final int transferred = mConnection.bulkTransfer(mReadEndpoint, mReadBuffer, readAmt,
        if (transferred < 0) {
            // This sucks: we get -1 on timeout, not 0 as preferred. 
            // We *should* use UsbRequest, except it has a bug/api oversight 
            // where there is no way to determine the number of bytes read 
            // in response :\ -- 
            return 0; 
        System.arraycopy(mReadBuffer, 0, dest, 0, transferred);
        return transferred;
Connect your IDE to all the code out there  Get Codota for Java