Package org.eclipse.rdf4j.common.io
Class ZipUtil
- java.lang.Object
-
- org.eclipse.rdf4j.common.io.ZipUtil
-
public class ZipUtil extends java.lang.Object
Zip-related utilities.
-
-
Field Summary
Fields Modifier and Type Field Description private static byte[]
MAGIC_NUMBER
Magic number for ZIP files (4 bytes: 0x04034b50).
-
Constructor Summary
Constructors Constructor Description ZipUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
extract(java.io.File zipFile, java.io.File destDir)
Extract the contents of a zipfile to a directory.static void
extract(java.util.zip.ZipFile zipFile, java.io.File destDir)
Extract the contents of a zipfile to a directory.static boolean
isZipStream(java.io.InputStream in)
Test if an input stream is a zip input stream by checking the "magic number"static void
writeEntry(java.util.zip.ZipFile zipFile, java.util.zip.ZipEntry entry, java.io.File destDir)
Write an entry to a zip file.
-
-
-
Method Detail
-
isZipStream
public static boolean isZipStream(java.io.InputStream in) throws java.io.IOException
Test if an input stream is a zip input stream by checking the "magic number"- Parameters:
in
- input stream- Returns:
- true if start of input stream matches magic number
- Throws:
java.io.IOException
-
extract
public static void extract(java.io.File zipFile, java.io.File destDir) throws java.io.IOException
Extract the contents of a zipfile to a directory.- Parameters:
zipFile
- the zip file to extractdestDir
- the destination directory- Throws:
java.io.IOException
- when something untoward happens during the extraction process
-
extract
public static void extract(java.util.zip.ZipFile zipFile, java.io.File destDir) throws java.io.IOException
Extract the contents of a zipfile to a directory.- Parameters:
zipFile
- the zip file to extractdestDir
- the destination directory- Throws:
java.io.IOException
- when something untoward happens during the extraction process
-
writeEntry
public static void writeEntry(java.util.zip.ZipFile zipFile, java.util.zip.ZipEntry entry, java.io.File destDir) throws java.io.IOException
Write an entry to a zip file.- Parameters:
zipFile
- the zip file to read fromentry
- the entry to processdestDir
- the file to write to- Throws:
java.io.IOException
- if the entry could not be processed
-
-