MCPcopy Create free account
hub / github.com/antlr/codebuff / read

Method read

corpus/java/training/guava/io/ByteStreams.java:849–867  ·  view source on GitHub ↗

Reads some bytes from an input stream and stores them into the buffer array b. This method blocks until len bytes of input data have been read into the array, or end of file is detected. The number of bytes read is returned, possibly zero. Does not close the stream. A caller can

(InputStream in, byte[] b, int off, int len)

Source from the content-addressed store, hash-verified

847 * @throws IOException if an I/O error occurs
848 */
849 @CanIgnoreReturnValue
850 // Sometimes you don't care how many bytes you actually read, I guess.
851 // (You know that it's either going to read len bytes or stop at EOF.)
852 public static int read(InputStream in, byte[] b, int off, int len) throws IOException {
853 checkNotNull(in);
854 checkNotNull(b);
855 if (len < 0) {
856 throw new IndexOutOfBoundsException("len is negative");
857 }
858 int total = 0;
859 while (total < len) {
860 int result = in.read(b, off + total, len - total);
861 if (result == -1) {
862 break;
863 }
864 total += result;
865 }
866 return total;
867 }
868}

Callers 8

contentEqualsMethod · 0.95
readFullyMethod · 0.95
copyMethod · 0.45
toByteArrayMethod · 0.45
exhaustMethod · 0.45
readMethod · 0.45
skipUpToMethod · 0.45
readBytesMethod · 0.45

Calls 1

checkNotNullMethod · 0.45

Tested by

no test coverage detected