Package io.quarkus.fs.util
Class ZipUtils
- java.lang.Object
-
- io.quarkus.fs.util.ZipUtils
-
public class ZipUtils extends Object
- Author:
- Alexey Loubyansky
-
-
Constructor Summary
Constructors Constructor Description ZipUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidcopyFromZip(Path source, Path target)static FileSystemnewFileSystem(URI uri, Map<String,Object> env)This call is not thread safe, a single of FileSystem can be created for the provided uri until it is closed.static FileSystemnewFileSystem(Path path)Constructs a new FileSystem to access the contents of a zip as a file system.static FileSystemnewFileSystem(Path path, ClassLoader classLoader)Deprecated.UsenewFileSystem(Path).static FileSystemnewZip(Path zipFile)static FileSystemnewZip(Path zipFile, Map<String,Object> env)In this version, callers can set whatever parameters they like for the FileSystem.static URItoZipUri(Path zipFile)static voidunzip(Path zipFile, Path targetDir)static OutputStreamwrapForJDK8232879(OutputStream original)This is a hack to get past the JDK-8232879 issue which causes CRC errors when writing out data to (jar) files using ZipFileSystem.static voidzip(Path src, Path zipFile)
-
-
-
Method Detail
-
unzip
public static void unzip(Path zipFile, Path targetDir) throws IOException
- Throws:
IOException
-
toZipUri
public static URI toZipUri(Path zipFile) throws IOException
- Throws:
IOException
-
copyFromZip
public static void copyFromZip(Path source, Path target) throws IOException
- Throws:
IOException
-
zip
public static void zip(Path src, Path zipFile) throws IOException
- Throws:
IOException
-
newZip
public static FileSystem newZip(Path zipFile) throws IOException
- Throws:
IOException
-
newZip
public static FileSystem newZip(Path zipFile, Map<String,Object> env) throws IOException
In this version, callers can set whatever parameters they like for the FileSystem. Note that these values always take precedence over whatever the library itself sets.- Throws:
IOException
-
newFileSystem
public static FileSystem newFileSystem(URI uri, Map<String,Object> env) throws IOException
This call is not thread safe, a single of FileSystem can be created for the provided uri until it is closed.- Parameters:
uri- The uri to the zip file.env- Env map.- Returns:
- A new FileSystem.
- Throws:
IOException- in case of a failure
-
newFileSystem
public static FileSystem newFileSystem(Path path) throws IOException
Constructs a new FileSystem to access the contents of a zip as a file system.- Parameters:
path- The zip file.- Returns:
- A new FileSystem instance
- Throws:
IOException- in case of a failure
-
newFileSystem
@Deprecated public static FileSystem newFileSystem(Path path, ClassLoader classLoader) throws IOException
Deprecated.UsenewFileSystem(Path). Providing a classLoader makes no difference, since the ZipFileSystemProvider is part of the FileSystemProvider.installedProviders() list. No classloader needs to be searched for a custom FileSystemProvider.This call is thread safe, a new FS is created for each invocation.- Parameters:
path- The zip file.classLoader- the classloader to locate the appropriate FileSystemProvider to open the path- Returns:
- A new FileSystem instance
- Throws:
IOException- in case of a failure
-
wrapForJDK8232879
public static OutputStream wrapForJDK8232879(OutputStream original)
This is a hack to get past the JDK-8232879 issue which causes CRC errors when writing out data to (jar) files using ZipFileSystem. TODO: Get rid of this method as soon as JDK-8232879 gets fixed and released in a public version- Parameters:
original- The original outputstream which will be wrapped into a new outputstream that delegates to this one.- Returns:
-
-