MCPcopy
hub / github.com/google/guava / skipSafely

Method skipSafely

guava/src/com/google/common/io/ByteStreams.java:879–882  ·  view source on GitHub ↗

Attempts to skip up to {@code n} bytes from the given input stream, but not more than {@code in.available()} bytes. This prevents {@code FileInputStream} from skipping more bytes than actually remain in the file, something that it {@linkplain java.io.FileInputStream#skip(long) specifies} it can do i

(InputStream in, long n)

Source from the content-addressed store, hash-verified

877 * {@code InputStream.skip()}.
878 */
879 private static long skipSafely(InputStream in, long n) throws IOException {
880 int available = in.available();
881 return available == 0 ? 0 : in.skip(min(available, n));
882 }
883
884 /**
885 * 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