### Question:
FileSamplerServiceImpl extends AbstractDataUtilsServiceImpl implements FileSamplerService { @SuppressWarnings("deprecation") @Override public byte[] sampleToByteArray(final String irodsAbsolutePath, final int sampleSize) throws FileNotFoundException, JargonException { log.info("sampleToByteArray()"); if (irodsAbsolutePath == null || irodsAbsolutePath.isEmpty()) { throw new IllegalArgumentException("null irodsAbsolutePath"); } if (sampleSize <= 0) { throw new IllegalArgumentException("sample size must be > 0"); } log.info("absolutePath:{}", irodsAbsolutePath); log.info("sampleSize:{}", sampleSize); if (sampleSize > MAX_SAMPLE_SIZE) { throw new IllegalArgumentException("sample size too large,use an input stream"); } log.info("getting input stream..."); InputStream inputStream = null; try { inputStream = new BufferedInputStream(getIrodsAccessObjectFactory().getIRODSFileFactory(getIrodsAccount()) .instanceIRODSFileInputStream(irodsAbsolutePath)); byte[] sample = IOUtils.toByteArray(inputStream, sampleSize); log.info("done..."); return sample; } catch (IOException e) { log.error("IOException reading from stream", e); throw new JargonException("io exception reading sample", e); } finally { if (inputStream != null) { IOUtils.closeQuietly(inputStream); } } } FileSamplerServiceImpl(final IRODSAccessObjectFactory irodsAccessObjectFactory,
			final IRODSAccount irodsAccount);  FileSamplerServiceImpl(); @SuppressWarnings("deprecation") @Override byte[] sampleToByteArray(final String irodsAbsolutePath, final int sampleSize); @Override String convertFileContentsToString(final String irodsAbsolutePath, final long maxSizeInKb); @Override void saveStringToFile(final String data, final String irodsAbsolutePath); static final Logger log; }### Answer:
@Test public void testSampleToByteArray() throws Exception { String testFileName = "testSampleToByteArray.txt"; String absPath = scratchFileUtils.createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH); String localFileName = FileGenerator.generateFileOfFixedLengthGivenName(absPath, testFileName, 100 * 1024); String targetIrodsCollection = testingPropertiesHelper .buildIRODSCollectionAbsolutePathFromTestProperties(testingProperties, IRODS_TEST_SUBDIR_PATH); IRODSAccount irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties); IRODSAccessObjectFactory accessObjectFactory = irodsFileSystem.getIRODSAccessObjectFactory(); DataTransferOperations dto = accessObjectFactory.getDataTransferOperations(irodsAccount); dto.putOperation(localFileName, targetIrodsCollection, "", null, null); FileSamplerService service = new FileSamplerServiceImpl(accessObjectFactory, irodsAccount); int sampleSize = 10 * 1024; byte[] actual = service.sampleToByteArray(targetIrodsCollection + "/" + testFileName, sampleSize); Assert.assertFalse("empty result", actual.length == 0); Assert.assertEquals("sampleSize not as requested", sampleSize, actual.length); }