com.atlassian.plugin.osgi.factory.transform
Class JarUtils

java.lang.Object
  extended by com.atlassian.plugin.osgi.factory.transform.JarUtils

public final class JarUtils
extends Object

Utility methods for getting stuff out of a jar.

Since:
2.6

Nested Class Summary
static interface JarUtils.Extractor<T>
           
 
Method Summary
static void closeQuietly(JarFile jarFile)
          Quietly close jar file.
static
<T> T
withJar(File file, JarUtils.Extractor<T> extractor)
          Extract something from a jar file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

withJar

public static <T> T withJar(File file,
                            JarUtils.Extractor<T> extractor)
Extract something from a jar file.

Correctly opens and closes the Jar file. Must not lazily access the Jar as it has an open/closed state.

Type Parameters:
T - the type of the thing to extract
Parameters:
file - the file that is the jar contents
extractor -
Returns:
the result of the extractor
Throws:
RuntimeException - if there are problems accessing the jar contents.

closeQuietly

public static void closeQuietly(JarFile jarFile)
Quietly close jar file.

Parameters:
jarFile - the file to close.


Copyright © 2012 Atlassian. All Rights Reserved.