### Question:
SessionClosingIRODSFileInputStream extends IRODSFileInputStream { @Override public void close() throws IOException { super.close(); try { getFileIOOperations().getIRODSSession().closeSession(getFileIOOperations().getIRODSAccount()); } catch (JargonException e) { throw new IOException("error in close session returned as IOException for method contracts"); } } protected  SessionClosingIRODSFileInputStream(final IRODSFile irodsFile, final FileIOOperations fileIOOperations); @Override void close();  }### Answer:
@Test public final void testRead() throws Exception { IRODSFileSystem irodsFileSystem = IRODSFileSystem.instance(); String testFileName = "testread.txt"; int fileLength = 40; String absPath = scratchFileUtils.createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH); org.irods.jargon.testutils.filemanip.FileGenerator.generateFileOfFixedLengthGivenName(absPath, testFileName, fileLength); String targetIrodsCollection = testingPropertiesHelper .buildIRODSCollectionAbsolutePathFromTestProperties(testingProperties, IRODS_TEST_SUBDIR_PATH); StringBuilder fileNameAndPath = new StringBuilder(); fileNameAndPath.append(absPath); fileNameAndPath.append(testFileName); IRODSAccount irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties); IRODSAccessObjectFactory accessObjectFactory = irodsFileSystem.getIRODSAccessObjectFactory(); DataTransferOperations dto = accessObjectFactory.getDataTransferOperations(irodsAccount); dto.putOperation(fileNameAndPath.toString(), targetIrodsCollection, testingProperties.getProperty(TestingPropertiesHelper.IRODS_RESOURCE_KEY), null, null); IRODSFileFactory irodsFileFactory = accessObjectFactory.getIRODSFileFactory(irodsAccount); IRODSFile irodsFile = irodsFileFactory.instanceIRODSFile(targetIrodsCollection, testFileName); SessionClosingIRODSFileInputStream fis = irodsFileFactory.instanceSessionClosingIRODSFileInputStream(irodsFile); ByteArrayOutputStream actualFileContents = new ByteArrayOutputStream(); int bytesRead = 0; int readBytes; while ((readBytes = fis.read()) > -1) { actualFileContents.write(readBytes); bytesRead++; } fis.close(); irodsFileSystem.closeAndEatExceptions(); Assert.assertEquals("whole file not read back", fileLength, bytesRead); }