com.dyuproject.util
Class ArchiveUtil

java.lang.Object
  extended by com.dyuproject.util.ArchiveUtil

public final class ArchiveUtil
extends Object

Util for extracting *.jar, *.war and *.zip archives.

Author:
David Yu
Date created:
Feb 25, 2008

Field Summary
static String[] SUPPORTED_FILES
          The suffixes of the files to support.
 
Constructor Summary
ArchiveUtil()
           
 
Method Summary
static boolean extract(File archive, File targetDir)
           
static boolean extract(File archive, File targetDir, boolean deleteOnExit)
           
static boolean extract(URL archive, File targetDir)
           
static boolean extract(URL archive, File targetDir, boolean deleteOnExit)
          Extracts the file archive to the target dir targetDir and deletes the files extracted upon jvm exit if the flag deleteOnExit is true.
static File getTempDir()
          Gets the temp dir (the sys property "java.io.tmpdir" if not overridden via setTempDir(File)).
static boolean isSupported(String resource)
          Returns true if the given resource is either a zip, jar or war file.
static void setTempDir(File tempDir)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUPPORTED_FILES

public static final String[] SUPPORTED_FILES
The suffixes of the files to support.

Constructor Detail

ArchiveUtil

public ArchiveUtil()
Method Detail

setTempDir

public static void setTempDir(File tempDir)

getTempDir

public static File getTempDir()
Gets the temp dir (the sys property "java.io.tmpdir" if not overridden via setTempDir(File)).


isSupported

public static boolean isSupported(String resource)
Returns true if the given resource is either a zip, jar or war file.


extract

public static boolean extract(File archive,
                              File targetDir)
                       throws IOException
Throws:
IOException

extract

public static boolean extract(File archive,
                              File targetDir,
                              boolean deleteOnExit)
                       throws IOException
Throws:
IOException

extract

public static boolean extract(URL archive,
                              File targetDir)
                       throws IOException
Throws:
IOException

extract

public static boolean extract(URL archive,
                              File targetDir,
                              boolean deleteOnExit)
                       throws IOException
Extracts the file archive to the target dir targetDir and deletes the files extracted upon jvm exit if the flag deleteOnExit is true.

Throws:
IOException


Copyright © 2008-2013. All Rights Reserved.