Code example for JarFile

Methods: getEntrygetInputStreamclose

0
	 *  
	 * @throws Exception 
	 */ 
	public void testGetInputStreamReturnsValidData() throws Exception { 
		byte[] defaultContents;
		JarFile defaultJarFile = new JarFile(file);
		try { 
			InputStream inputStream = defaultJarFile.getInputStream(defaultJarFile.getEntry(SAMPLE_JAR_CLASS));
			try { 
				defaultContents = IOUtils.toByteArray(inputStream);
			} finally { 
				inputStream.close();
			} 
		} finally { 
			defaultJarFile.close();
		} 
 
		NonLockingJarFileSpy jarFile = new NonLockingJarFileSpy(file);
		byte[] nonLockedContents = IOUtils.toByteArray(jarFile.getInputStream(jarFile.getEntry(SAMPLE_JAR_CLASS)));
 
Experience pair programming with AI  Get Codota for Java