public class Files extends Object
| Constructor and Description |
|---|
Files() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addDirectoryContentsToZip(File zipFile,
File directory)
Convenience method for addFilesToZip(File zipFile, Map
|
static void |
addDirectoryToZip(File zipFile,
File directory)
Convenience method for addFilesToZip(File zipFile, Map
|
static void |
addFilesToZip(File zipFile,
File[] files,
File baseDirectory)
Convenience method for addFilesToZip(File zipFile, Map
|
static void |
addFilesToZip(File zipFile,
Map<String,File> files)
This is where the action happens.
|
static void |
copy(File from,
File to) |
static String |
encodeURI(String path)
Encodes a file path for use as a URI.
|
static Map<String,File> |
listFilesRecursively(File directory,
boolean includeDirectories)
Lists all files recursively, starting at `directory`.
|
static Map<String,File> |
listFilesRecursively(File directory,
URI base,
boolean includeDirectories)
Lists all files recursively, starting at `directory`, resolving their
relative paths against `base`.
|
static List<String> |
listZipFiles(File zipfile)
Does not actually load the files, since that could potentially eat up your RAM.
|
static String |
read(File file)
Read text from file
|
static void |
unzip(File zip,
File dir)
Unzip the ZIP-file `zip` to the directory `dir`.
|
static void |
zip(File dir,
File zip)
Zip up the directory `dir` into a new ZIP-file `zip`.
|
public static void addDirectoryToZip(File zipFile, File directory) throws IOException
zipFile - The ZIP-file.directory - The directory to add to the ZIP.IOExceptionpublic static void addDirectoryContentsToZip(File zipFile, File directory) throws IOException
zipFile - The ZIP-file.directory - The directory to add to the ZIP.IOExceptionpublic static Map<String,File> listFilesRecursively(File directory, boolean includeDirectories) throws IOException
directory - base - IOExceptionpublic static Map<String,File> listFilesRecursively(File directory, URI base, boolean includeDirectories) throws IOException
directory - base - IOExceptionpublic static List<String> listZipFiles(File zipfile)
zipfile - public static void addFilesToZip(File zipFile, File[] files, File baseDirectory) throws IOException
zipFile - The ZIP-file.files - The list of files to append to the ZIP-file.baseDirectory - The directory to resolve the relative file paths against.IOExceptionpublic static void addFilesToZip(File zipFile, Map<String,File> files) throws IOException
zipFile - The ZIP file.files - A map of all the files to add to the ZIP file, where the key
is the ZIP entry name to use (the relative file paths).IOExceptionpublic static void unzip(File zip, File dir) throws IOException
zip - ZIP filedir - output directoryIOExceptionpublic static void zip(File dir, File zip) throws IOException
dir - zip - IOExceptionpublic static void copy(File from, File to) throws IOException
IOExceptionpublic static String encodeURI(String path)
path - Copyright © 2012–2016 The DAISY Consortium. All rights reserved.