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

Method skipSafely

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

Attempts to skip up to n bytes from the given input stream, but not more than in.available() bytes. This prevents FileInputStream from skipping more bytes than actually remain in the file, something that it plain FileInputStream#skip(long) specifies it can do in its Ja

(InputStream in, long n)

Source from the content-addressed store, hash-verified

797 * {@code InputStream.skip()}.
798 */
799 private static long skipSafely(InputStream in, long n) throws IOException {
800 int available = in.available();
801 return available == 0 ? 0 : in.skip(Math.min(available, n));
802 }
803
804 /**
805 * Process the bytes of the given input stream using the given processor.

Callers 1

skipUpToMethod · 0.95

Calls 3

availableMethod · 0.45
skipMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected