/** * Skips a set amount of bytes such that reading can be stopped and started again later if not * enough bytes are available. * * <p>Returns {@link #READ_RESULT_CONTINUE} if all bytes have been skipped. Reset {@link * #bytesState} to {@code 0} before calling to indicate a new set of bytes should be skipped. * * @param inputStream The input stream from which bytes should be skipped * @param totalBytes The total size of bytes to be skipped * @return One of the {@code RESULT_*} flags defined in this class */ private int skipBytesInternal(NonBlockingInputStream inputStream, int totalBytes) { if (bytesState >= totalBytes) { return READ_RESULT_CONTINUE; } int remainingBytes = totalBytes - bytesState; int additionalBytesRead = inputStream.skip(remainingBytes); return updateBytesState(additionalBytesRead, totalBytes); }