ByteArrayInputStream&ByteArrayOutputStream源码分析

#ByteArrayInputStream

源码

```
public synchronized int read(byte b[], int off, int len) {
if (b == null) {
throw new NullPointerException();
} else if (off < 0 || len < 0 || len > b.length - off) {
throw new IndexOutOfBoundsException();
}

    if (pos >= count) {
        return -1;
    }

    int avail = count - pos;
    if (len > avail) {
        len = avail;
    }
    if (len <= 0) {
        return 0;
    }
    System.arraycopy(buf, pos, b, off, len);
    pos += len;
    return len;
}

```

#ByteArrayOutputStream

原文地址:https://www.cnblogs.com/xd03122049/p/6550724.html