### Question:
Stream2StreamAOImpl extends IRODSGenericAO implements Stream2StreamAO { @Override public void streamClasspathResourceToIRODSFile(final String resourcePath, final String irodsFileAbsolutePath) throws JargonException { if (resourcePath == null || resourcePath.isEmpty()) { throw new IllegalArgumentException("null or empty resourcePath"); } if (irodsFileAbsolutePath == null || irodsFileAbsolutePath.isEmpty()) { throw new IllegalArgumentException("null or empty irodsFileAbsolutePath"); } IRODSFile irodsTarget = getIRODSFileFactory().instanceIRODSFile(irodsFileAbsolutePath); irodsTarget.getParentFile().mkdirs(); irodsTarget.delete(); InputStream inputStream = new BufferedInputStream(this.getClass().getResourceAsStream(resourcePath)); IRODSFileOutputStream irodsFileOutputStream = getIRODSFileFactory() .instanceIRODSFileOutputStream(irodsFileAbsolutePath); byte[] buff = new byte[4096]; try { int i = 0; while ((i = inputStream.read(buff)) > -1) { irodsFileOutputStream.write(buff, 0, i); } } catch (IOException ioe) { log.error("io exception reading rule data from resource", ioe); throw new JargonException("error reading rule from resource", ioe); } finally { try { irodsFileOutputStream.close(); } catch (IOException e) { } try { inputStream.close(); } catch (IOException e) { } } } Stream2StreamAOImpl(final IRODSSession irodsSession, final IRODSAccount irodsAccount); @Override void streamBytesToIRODSFile(final byte[] bytesToStream, final IRODSFile irodsTargetFile); @Override TransferStatistics transferStreamToFileUsingIOStreams(final InputStream inputStream, final File targetFile,
			final long length, final int readBuffSize); @Override TransferStatistics streamToStreamCopyUsingStandardIO(final InputStream inputStream,
			final OutputStream outputStream); @Override void streamToStreamCopy(final InputStream inputStream, final OutputStream outputStream); @Override byte[] streamFileToByte(final IRODSFile irodsFile); @Override void streamClasspathResourceToIRODSFile(final String resourcePath, final String irodsFileAbsolutePath); static final Logger log; }### Answer:
@Test public void testStreamResourceToIRODSFile() throws Exception { String testFileName = "testStreamResourceToIRODSFile.r"; String sourceFileName = "/rules/rulemsiGetIcatTime.r"; String targetIrodsCollection = testingPropertiesHelper .buildIRODSCollectionAbsolutePathFromTestProperties(testingProperties, IRODS_TEST_SUBDIR_PATH); IRODSAccount irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties); IRODSAccessObjectFactory irodsAccessObjectFactory = irodsFileSystem.getIRODSAccessObjectFactory(); Stream2StreamAO stream2StreamAO = irodsAccessObjectFactory.getStream2StreamAO(irodsAccount); stream2StreamAO.streamClasspathResourceToIRODSFile(sourceFileName, targetIrodsCollection + "/" + testFileName); IRODSFile targetIrodsFile = irodsAccessObjectFactory.getIRODSFileFactory(irodsAccount) .instanceIRODSFile(targetIrodsCollection + "/" + testFileName); Assert.assertTrue("file does not exist", targetIrodsFile.exists()); Assert.assertTrue("no data in target file", targetIrodsFile.length() > 0); }