Top Description Constructors Methods
org.glassfish.grizzly.http.server.util

public Class ExpandJar

extends Object
Class Inheritance
Imports
java.io.BufferedOutputStream, .File, .FileInputStream, .FileOutputStream, .IOException, .InputStream, java.net.JarURLConnection, .URL, java.nio.channels.FileChannel, java.util.Enumeration, java.util.jar.JarEntry, .JarFile

Expand out a jar. Adapted from Tomcat's org.apache.catalina.startup.ExpendWar classes
Author
Jeanfrancois Arcand

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static boolean
copy(File
File object representing the source
src
,
File
File object representing the destination
dest
)

Copy the specified file or directory to the destination.

public static boolean
delete(File
File object representing the directory to be deleted
dir
)

Delete the specified directory, including all of its contents and subdirectories recursively.

public static boolean
deleteDir(File
File object representing the directory to be deleted
dir
)

Delete the specified directory, including all of its contents and subdirectories recursively.

public static String

Returns:

Absolute path as in java.io.File#getAbsolutePath() of location where to find expanded jar.
expand
(URL
URL of the web application archive to be expanded (must start with "jar:")
jar
)

Expand the jar file found at the specified URL into an unpacked directory structure, and return the absolute pathname to the expanded directory.

public static String

Returns:

Absolute path as in java.io.File#getAbsolutePath() of location where to find expanded jar.
expand
(URL
URL of the web application archive to be expanded (must start with "jar:")
jar
,
String
the folder where the file will be expanded
workFolder
)

Expand the jar file found at the specified URL into an unpacked directory structure, and return the absolute pathname to the expanded directory.

public static String

Returns:

Absolute path as in java.io.File#getAbsolutePath() of location where to find expanded jar.
expand
(URL
URL of the web application archive to be expanded (must start with "jar:")
jar
,
String
Context path name for web application
pathname
,
String dirname)

Expand the jar file found at the specified URL into an unpacked directory structure, and return the absolute pathname to the expanded directory.

protected static void
expand(InputStream
InputStream to be copied
input
,
File
Document base directory into which we are expanding
docBase
,
String
Relative pathname of the file to be created
name
)

Expand the specified input stream into the specified directory, creating a file named from the specified relative path.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ExpandJarback to summary
public ExpandJar()

Method Detail

copyback to summary
public static boolean copy(File src, File dest)

Copy the specified file or directory to the destination.

Parameters
src:File

File object representing the source

dest:File

File object representing the destination

deleteback to summary
public static boolean delete(File dir)

Delete the specified directory, including all of its contents and subdirectories recursively.

Parameters
dir:File

File object representing the directory to be deleted

deleteDirback to summary
public static boolean deleteDir(File dir)

Delete the specified directory, including all of its contents and subdirectories recursively.

Parameters
dir:File

File object representing the directory to be deleted

expandback to summary
public static String expand(URL jar) throws IOException

Expand the jar file found at the specified URL into an unpacked directory structure, and return the absolute pathname to the expanded directory.

Parameters
jar:URL

URL of the web application archive to be expanded (must start with "jar:")

Returns:String

Absolute path as in java.io.File#getAbsolutePath() of location where to find expanded jar.

Exceptions
IOException:
if an input/output error was encountered during expansion
IllegalArgumentException:
if this is not a "jar:" URL
expandback to summary
public static String expand(URL jar, String workFolder) throws IOException

Expand the jar file found at the specified URL into an unpacked directory structure, and return the absolute pathname to the expanded directory.

Parameters
jar:URL

URL of the web application archive to be expanded (must start with "jar:")

workFolder:String

the folder where the file will be expanded

Returns:String

Absolute path as in java.io.File#getAbsolutePath() of location where to find expanded jar.

Exceptions
IOException:
if an input/output error was encountered during expansion
IllegalArgumentException:
if this is not a "jar:" URL
expandback to summary
public static String expand(URL jar, String pathname, String dirname) throws IOException

Expand the jar file found at the specified URL into an unpacked directory structure, and return the absolute pathname to the expanded directory.

Parameters
jar:URL

URL of the web application archive to be expanded (must start with "jar:")

pathname:String

Context path name for web application

Returns:String

Absolute path as in java.io.File#getAbsolutePath() of location where to find expanded jar.

Exceptions
IOException:
if an input/output error was encountered during expansion
IllegalArgumentException:
if this is not a "jar:" URL
expandback to summary
protected static void expand(InputStream input, File docBase, String name) throws IOException

Expand the specified input stream into the specified directory, creating a file named from the specified relative path.

Parameters
input:InputStream

InputStream to be copied

docBase:File

Document base directory into which we are expanding

name:String

Relative pathname of the file to be created

Exceptions
IOException:
if an input/output error occurs