论IO流之ByteArrayInputStream
? ? ? ByteArrayInputStream继承自InputStream抽象类,是以内存中的一个字节数组作为流来进行读写操作。在该流内中包含一个内部缓冲区数组,该缓冲区包含从流中读取的字节。源码如下:
/** * Skips n bytes of input from this input stream. Fewer * bytes might be skipped if the end of the input stream is reached. * The actual number k * of bytes to be skipped is equal to the smaller * of n and count-pos. * The value k is added into pos * and k is returned. * * @param n the number of bytes to be skipped. * @return the actual number of bytes skipped. */public synchronized long skip(long n) {if (pos + n > count) { n = count - pos;}if (n < 0) { return 0;}pos += n;return n;}