Class ArchiveUtils
public class ArchiveUtils extends Object
-
Constructor Summary
Constructors Constructor Description ArchiveUtils() -
Method Summary
Modifier and Type Method Description static voidjar(File directory, File output)Builds a JAR file from the contents of a directory on the filesystem (recursively).static StringrewritePath(String oldValue, String newValue)Derives a new file path, in whole or in part, from an existing path.static voidunzip(File source, File target)Unzips thesourcefile to thetargetdirectory.static voidzip(File directory, File output)Builds a ZIP file from the contents of a directory on the filesystem (recursively).
-
Constructor Details
-
ArchiveUtils
public ArchiveUtils()
-
-
Method Details
-
jar
Builds a JAR file from the contents of a directory on the filesystem (recursively). Adapted from stackoverflow solution.Refer to http://stackoverflow.com/questions/1281229/how-to-use-jaroutputstream-to-create-a-jar-file
- Parameters:
directory- the directory containing the content to be xzipped upoutput- the zip file to be written to- Throws:
IOException- when any I/O error occurs
-
zip
Builds a ZIP file from the contents of a directory on the filesystem (recursively).Refer to http://stackoverflow.com/questions/1281229/how-to-use-jaroutputstream-to-create-a-jar-file
- Parameters:
directory- the directory containing the content to be xzipped upoutput- the zip file to be written to- Throws:
IOException- when any I/O error occurs
-
unzip
Unzips thesourcefile to thetargetdirectory.- Parameters:
source- The file to be unzippedtarget- The directory to which the source file should be unzipped- Throws:
IOException- when any I/O error occurs
-
rewritePath
Derives a new file path, in whole or in part, from an existing path. The following use cases are supported explicitly:-
Rename a file (example: smartgwt-lgpl.jar)
ArchiveUtils.rewritePath("smartgwtee-4.1d/lib/smartgwt.jar", "smartgwt-lgpl.jar"); -
Move to another directory (example: target/smartgwt.jar)
ArchiveUtils.rewritePath("smartgwtee-4.1d/lib/smartgwt.jar", "target"); - Move and rename (example: target/smartgwt-lgpl.jar)
ArchiveUtils.rewritePath("smartgwtee-4.1d/lib/smartgwt.jar", "target/smartgwt-lgpl.jar"); - Move to new root directory, preserving some part of the existing path
-
example: doc/api/com/isomorphic/servlet/IDACall.html
ArchiveUtils.rewritePath("smartgwtee-4.1d/doc/javadoc/com/isomorphic/servlet/IDACall.html","doc/api/#javadoc"); -
example: doc/api/com/isomorphic/servlet/network/FileAssembly.html
ArchiveUtils.rewritePath("smartgwtee-4.1d/doc/javadoc/com/isomorphic/servlet/CompressionFilter.html", "doc/api/#javadoc/network");
-
example: doc/api/com/isomorphic/servlet/IDACall.html
- Parameters:
oldValue- the existing pathnewValue- the value to use for the new path, including optional tokens- Returns:
- the new path
-
Rename a file (example: smartgwt-lgpl.jar)
-