### Question:
SessionClosingIRODSFileOutputStream extends IRODSFileOutputStream { @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  SessionClosingIRODSFileOutputStream(final IRODSFile irodsFile, final FileIOOperations fileIOOperations); protected  SessionClosingIRODSFileOutputStream(final IRODSFile irodsFile, final FileIOOperations fileIOOperations,
			final OpenFlags openFlags); @Override void close();  }### Answer:
@Test public final void testWriteIntAndClose() throws Exception { String testFileName = "testWriteIntAndClose.csv"; String targetIrodsCollection = testingPropertiesHelper .buildIRODSCollectionAbsolutePathFromTestProperties(testingProperties, IRODS_TEST_SUBDIR_PATH); IRODSAccount irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties); IRODSAccessObjectFactory accessObjectFactory = irodsFileSystem.getIRODSAccessObjectFactory(); IRODSFileFactory irodsFileFactory = accessObjectFactory.getIRODSFileFactory(irodsAccount); IRODSFile irodsFile = irodsFileFactory.instanceIRODSFile(targetIrodsCollection + '/' + testFileName); SessionClosingIRODSFileOutputStream irodsFileOutputStream = irodsFileFactory .instanceSessionClosingIRODSFileOutputStream(irodsFile); int writtenInt = 3; irodsFileOutputStream.write(writtenInt); irodsFileOutputStream.close(); Assert.assertTrue("irodsFile not closed", irodsFile.getFileDescriptor() == -1); }