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

Method read

output/java_guava/1.4.19/ByteStreams.java:882–901  ·  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

880 */
881
882 @CanIgnoreReturnValue
883 // Sometimes you don't care how many bytes you actually read, I guess.
884 // (You know that it's either going to read len bytes or stop at EOF.)
885 public static int read(InputStream in, byte[] b, int off, int len) throws IOException {
886 checkNotNull(in);
887 checkNotNull(b);
888 if (len < 0) {
889 throw new IndexOutOfBoundsException("len is negative");
890 }
891
892 int total = 0;
893 while (total < len) {
894 int result = in.read(b, off + total, len - total);
895 if (result == -1) {
896 break;
897 }
898 total += result;
899 }
900 return total;
901 }
902}

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