public class CopyUtil extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
CopyUtil.Filter
For excluding files and folders from being copied by
recursiveCopy(File, File, Filter) . |
Constructor and Description |
---|
CopyUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
copyFile(File to,
File from)
Copy the contents of a file.
|
static void |
copyStream(OutputStream to,
InputStream from)
Copy one stream to another until the input stream has no more data.
|
static void |
copyStreamToFile(File to,
InputStream from)
Copy the contents of a stream to the given file.
|
static void |
recursiveCopy(File to,
File from,
CopyUtil.Filter filter)
Recursively copy a directory.
|
static void |
recursiveDeleteOnExit(File rootDir)
Recursively set this directory to be deleted on termination of the JVM
(using
File.deleteOnExit() ). |
static void |
unzip(File dir,
ZipInputStream from)
Copy a zip stream to the given directory.
|
public static void recursiveCopy(File to, File from, CopyUtil.Filter filter) throws IOException
to
- The file or directory to be copied to. Must already exist and be
the same type as from (i.e. file or directory)from
- The file or directory being copied from.filter
- A filter for which files to include or exclude (or null if no all
files are to be copied).IOException
public static void copyFile(File to, File from) throws IOException
to
- The file to be copied to (must already exist).from
- The file to be copied from.IOException
public static void copyStreamToFile(File to, InputStream from) throws IOException
to
- A file (which may not yet exist).from
- The stream from which to copy (must be open).IOException
public static void copyStream(OutputStream to, InputStream from) throws IOException
to
- The open stream to write to.from
- The open stream to read from.IOException
public static void unzip(File dir, ZipInputStream from) throws IOException
dir
- The target directory.from
- The zip input stream to copy.IOException
public static void recursiveDeleteOnExit(File rootDir)
File.deleteOnExit()
).rootDir
- The directory to be deleted on exit.Copyright © 2013-2015 JBoss, a division of Red Hat. All Rights Reserved.