|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjetbrains.buildServer.util.ArchiveUtil
public abstract class ArchiveUtil
Provides utils to archive and extract files from zip archive Date: 15.05.2008 Time: 8:25:20
| Field Summary | |
|---|---|
static java.lang.String |
DEFAULT_ZIP_ENCODING
|
| Constructor Summary | |
|---|---|
ArchiveUtil()
|
|
| Method Summary | |
|---|---|
static java.io.InputStream |
extractEntry(java.util.zip.ZipInputStream input,
java.lang.String path)
Extracts and returns the input stream for the file specified inside a zip stream. |
static org.apache.commons.compress.archivers.ArchiveInputStream |
getArchiveInputStream(ArchiveType archiveType,
java.io.InputStream inputStream)
Returns the ArchiveInputStream for the specified archiveType. |
static org.apache.commons.compress.archivers.ArchiveInputStream |
getArchiveInputStream(java.lang.String name,
java.io.InputStream inputStream)
Returns the ArchiveInputStream for the specified name of the resource. |
static ArchiveType |
getArchiveType(java.lang.String name)
Determines the archive type based on a file name. |
static java.io.File |
getPackedFile(java.io.File file)
Adds ".gz" to the file name |
static java.lang.String |
getPackedFileName(java.lang.String fileName)
adds ".gz" to the given file name |
static boolean |
isPackedFile(java.io.File file)
|
static boolean |
isPackedFileName(java.lang.String fileName)
|
static byte[] |
packBytes(byte[] unpacked)
|
static java.io.File |
packFile(java.io.File srcFile)
Creates a packed file "file.ext.gz" from the given file "file.ext". |
static void |
packFileTo(java.io.File dstFile,
java.io.File srcFile)
Packs the content of the source file to the destination file. |
static void |
packStream(java.io.OutputStream out,
java.io.InputStream in)
Packs the entire content of the input stream and puts it into the output stream. |
static boolean |
packZip(java.io.File root,
java.io.FilenameFilter filter,
java.util.zip.ZipOutputStream output)
Same as packZip(java.io.File, java.util.zip.ZipOutputStream), but allows to specify
the filename filter additionally. |
static boolean |
packZip(java.io.File root,
java.util.zip.ZipOutputStream output)
Packs a file (or a directory) to a zip archive. |
static byte[] |
unpackBytes(byte[] packed)
|
static void |
unpackStream(java.io.OutputStream out,
java.io.InputStream in)
Unpacks the entire content of the input stream and puts it into the output stream. |
static boolean |
unpackZip(java.io.File zip,
java.lang.String pathPrefix,
java.io.File targetDir)
Extract files from zip archive |
static boolean |
unpackZip(java.util.zip.ZipInputStream input,
java.io.File targetDir)
Extracts the compressed files from the zip input stream input
and stores them in the targetDir. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String DEFAULT_ZIP_ENCODING
| Constructor Detail |
|---|
public ArchiveUtil()
| Method Detail |
|---|
@NotNull
public static ArchiveType getArchiveType(@NotNull
java.lang.String name)
Currently the following extensions are supported:
.zip, .nupkg, .sit
.jar, .war, .ear, .apk
.tar.gz, .tgz, .tar.gzip
.tar
name - the file or resource name
@Nullable
public static org.apache.commons.compress.archivers.ArchiveInputStream getArchiveInputStream(@NotNull
ArchiveType archiveType,
@NotNull
java.io.InputStream inputStream)
throws java.io.IOException
ArchiveInputStream for the specified archiveType.
archiveType - the type of archiveinputStream - the input that should be read
ArchiveInputStream, or null if nothing matches.
java.io.IOException - if I/O error occurs
@Nullable
public static org.apache.commons.compress.archivers.ArchiveInputStream getArchiveInputStream(@NotNull
java.lang.String name,
@NotNull
java.io.InputStream inputStream)
throws java.io.IOException
ArchiveInputStream for the specified name of the resource.
name - the name of the resourceinputStream - the input that should be read
ArchiveInputStream, or null if nothing matches.
java.io.IOException - if I/O error occurs
public static boolean unpackZip(@NotNull
java.io.File zip,
@NotNull
java.lang.String pathPrefix,
@NotNull
java.io.File targetDir)
zip - .zip file to extractpathPrefix - path prefix to extract from zip. Use "" to extract all filestargetDir - target folder to extract
public static boolean unpackZip(@NotNull
java.util.zip.ZipInputStream input,
@NotNull
java.io.File targetDir)
input
and stores them in the targetDir.
The input is closed in the end.
input - zip input streamtargetDir - the target directory
public static boolean packZip(java.io.File root,
java.util.zip.ZipOutputStream output)
Files and directories have relative names, for instance, for the following tree:
foo/bar/File1
/File2
/baz/File3
the call packZip(barDirectory, output) creates a zip with "/File1", "/File2" and "/baz/File3" files,
and calls packZip(bazDirectory, output) and packZip(file3, output) both create a zip
with a single file "/File3".
Output stream is closed in the end.
root - root file or directoryoutput - the zip stream to write to
public static boolean packZip(java.io.File root,
java.io.FilenameFilter filter,
java.util.zip.ZipOutputStream output)
packZip(java.io.File, java.util.zip.ZipOutputStream), but allows to specify
the filename filter additionally.
root - root file or directoryfilter - file name filteroutput - the zip stream to write to
public static void packStream(@NotNull
java.io.OutputStream out,
@NotNull
java.io.InputStream in)
throws java.io.IOException
out - output streamin - input stream
java.io.IOException
public static void unpackStream(@NotNull
java.io.OutputStream out,
@NotNull
java.io.InputStream in)
throws java.io.IOException
out - output streamin - input stream
java.io.IOException@Nullable public static byte[] packBytes(byte[] unpacked)
@Nullable public static byte[] unpackBytes(byte[] packed)
@Nullable
public static java.io.InputStream extractEntry(@NotNull
java.util.zip.ZipInputStream input,
@NotNull
java.lang.String path)
throws java.io.IOException
null is returned.
Note: method does not close the input.
input - the zip input streampath - relative path of the file to extract
java.io.IOException - if I/O error occurs
@NotNull
public static java.io.File getPackedFile(@NotNull
java.io.File file)
file - file
@NotNull
public static java.lang.String getPackedFileName(@NotNull
java.lang.String fileName)
fileName - file name
public static boolean isPackedFile(@NotNull
java.io.File file)
public static boolean isPackedFileName(@NotNull
java.lang.String fileName)
@NotNull
public static java.io.File packFile(@NotNull
java.io.File srcFile)
throws java.io.IOException
srcFile - the given file
java.io.IOException - if a problem occurs during file operations
public static void packFileTo(java.io.File dstFile,
java.io.File srcFile)
throws java.io.IOException
dstFile - destination filesrcFile - source file
java.io.IOException - if a problem occurs during file operations
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||