public class FileSystemZip
extends java.lang.Object
implements java.lang.AutoCloseable
FileSystem API.| Modifier and Type | Class and Description |
|---|---|
class |
FileSystemZip.Entry
The entry for a file in the zip file.
|
| Constructor and Description |
|---|
FileSystemZip(java.io.File file)
Construct a new file system zip.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDirectory(java.lang.String name)
Add a directory to the zip file.
|
void |
addEntry(java.lang.String name,
byte[] bytes)
Add an entry to the zip file.
|
void |
close() |
void |
forEach(java.util.function.Consumer<FileSystemZip.Entry> consumer)
Iterate over all entries in the zip file.
|
FileSystemZip.Entry |
getEntry(java.lang.String name)
Get an entry from the zip file.
|
java.io.File |
getFile() |
java.nio.file.Path |
getRootPath() |
boolean |
hasDirectory(java.lang.String name)
Check if an entry exists and is a directory.
|
boolean |
hasEntry(java.lang.String name)
Check if an entry exists.
|
boolean |
hasFile(java.lang.String name)
Check if an entry exists and is a file.
|
public FileSystemZip(java.io.File file)
throws java.io.IOException,
java.net.URISyntaxException
file - The file to read/writejava.io.IOException - If an I/O error occursjava.net.URISyntaxException - If the file path is invalidpublic java.io.File getFile()
public java.nio.file.Path getRootPath()
public void addEntry(java.lang.String name,
@Nullable
byte[] bytes)
throws java.io.IOException
bytes is null a directory will be created.name - The name of the entrybytes - The data of the entryjava.io.IOException - If an I/O error occurspublic void addDirectory(java.lang.String name)
throws java.io.IOException
name - The name of the directoryjava.io.IOException - If an I/O error occurspublic FileSystemZip.Entry getEntry(java.lang.String name) throws java.io.FileNotFoundException
name - The name of the entryjava.io.FileNotFoundException - If the entry does not existpublic boolean hasEntry(java.lang.String name)
name - The name of the entrypublic boolean hasFile(java.lang.String name)
name - The name of the entrypublic boolean hasDirectory(java.lang.String name)
name - The name of the entrypublic void forEach(java.util.function.Consumer<FileSystemZip.Entry> consumer) throws java.io.IOException
consumer - The consumer to call for each entryjava.io.IOException - If an I/O error occurspublic void close()
throws java.lang.Exception
close in interface java.lang.AutoCloseablejava.lang.Exception