public int read()

in src/main/java/com/amazonaws/encryptionsdk/CryptoInputStream.java [138:170]


  public int read(final byte[] b, final int off, final int len)
      throws IllegalArgumentException, IOException, BadCiphertextException {
    assertNonNull(b, "b");

    if (len < 0 || off < 0) {
      throw new IllegalArgumentException(
          String.format("Invalid values for offset: %d and length: %d", off, len));
    }

    if (b.length == 0 || len == 0) {
      return 0;
    }

    // fill the output bytes if there aren't any left to return.
    if ((outEnd_ - outStart_) <= 0) {
      int newBytesLen = 0;

      // Block until a byte is read or end of stream in the underlying
      // stream is reached.
      while (newBytesLen == 0) {
        newBytesLen = fillOutBytes();
      }
      if (newBytesLen < 0) {
        return -1;
      }
    }

    final int copyLen = Math.min((outEnd_ - outStart_), len);
    System.arraycopy(outBytes_, outStart_, b, off, copyLen);
    outStart_ += copyLen;

    return copyLen;
  }