### Question:
RemoteExecutionBinaryResultInputStream extends InputStream { @Override public long skip(final long n) throws IOException { if (n <= 0) { throw new IllegalArgumentException("attempt to skip a neg or zero amount"); } int skippedSoFar = 0; int read = 0; while (read > -1 && skippedSoFar < n) { read = read(new byte[(int) n]); if (read > -1) { skippedSoFar += read; } } return skippedSoFar; } RemoteExecutionBinaryResultInputStream(final IRODSMidLevelProtocol irodsCommands, final int fileDescriptor); int getFileDescriptor(); @Override int available(); @Override void close(); @Override synchronized void mark(final int readlimit); @Override boolean markSupported(); @Override int read(final byte[] b, final int off, final int len); @Override int read(final byte[] b); @Override void reset(); @Override long skip(final long n); @Override int read(); static final Logger log; }### Answer:
@Test public void testSkip() throws Exception { if (!testingPropertiesHelper.isTestRemoteExecStream(testingProperties)) { return; } int testLen = 2000000; int skipLen = 1500000; String cmd = "test_execstream.py"; String args = String.valueOf(testLen); String host = ""; IRODSAccount irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties); IRODSFileSystem irodsFileSystem = IRODSFileSystem.instance(); EnvironmentalInfoAO environmentalInfoAO = irodsFileSystem.getIRODSAccessObjectFactory() .getEnvironmentalInfoAO(irodsAccount); IRODSServerProperties props = environmentalInfoAO.getIRODSServerPropertiesFromIRODSServer(); if (!props.isTheIrodsServerAtLeastAtTheGivenReleaseVersion(RemoteExecuteServiceImpl.STREAMING_API_CUTOFF)) { irodsFileSystem.closeAndEatExceptions(); return; } if (props.isAtLeastIrods410()) { return; } CollectionAO collectionAO = irodsFileSystem.getIRODSAccessObjectFactory().getCollectionAO(irodsAccount); CollectionAOImpl collectionAOImpl = (CollectionAOImpl) collectionAO; IRODSMidLevelProtocol irodsCommands = collectionAOImpl.getIRODSProtocol(); RemoteExecutionService remoteExecuteService = RemoteExecuteServiceImpl.instance(irodsCommands, cmd, args, host); InputStream inputStream = remoteExecuteService.executeAndStream(); inputStream.skip(skipLen); BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder sb = new StringBuilder(); String line = null; while ((line = br.readLine()) != null) { sb.append(line + "\n"); } br.close(); String result = sb.toString(); irodsFileSystem.close(); Assert.assertEquals("did not get expected data length", testLen - skipLen, result.length()); }