Errai 3.0.1-SNAPSHOT

org.jboss.errai.cdi.server.gwt.util
Class CopyUtil

java.lang.Object
  extended by org.jboss.errai.cdi.server.gwt.util.CopyUtil

public class CopyUtil
extends Object

A utility class for copying files and directories.

Author:
Max Barkley

Nested Class Summary
static interface CopyUtil.Filter
          For excluding files and folders from being copied by recursiveCopy(File, File, Filter).
 
Constructor Summary
CopyUtil()
           
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CopyUtil

public CopyUtil()
Method Detail

recursiveCopy

public static void recursiveCopy(File to,
                                 File from,
                                 CopyUtil.Filter filter)
                          throws IOException
Recursively copy a directory.

Parameters:
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).
Throws:
IOException

copyFile

public static void copyFile(File to,
                            File from)
                     throws IOException
Copy the contents of a file.

Parameters:
to - The file to be copied to (must already exist).
from - The file to be copied from.
Throws:
IOException

copyStreamToFile

public static void copyStreamToFile(File to,
                                    InputStream from)
                             throws IOException
Copy the contents of a stream to the given file.

Parameters:
to - A file (which may not yet exist).
from - The stream from which to copy (must be open).
Throws:
IOException

copyStream

public static void copyStream(OutputStream to,
                              InputStream from)
                       throws IOException
Copy one stream to another until the input stream has no more data.

Parameters:
to - The open stream to write to.
from - The open stream to read from.
Throws:
IOException

unzip

public static void unzip(File dir,
                         ZipInputStream from)
                  throws IOException
Copy a zip stream to the given directory.

Parameters:
dir - The target directory.
from - The zip input stream to copy.
Throws:
IOException

recursiveDeleteOnExit

public static void recursiveDeleteOnExit(File rootDir)
Recursively set this directory to be deleted on termination of the JVM (using File.deleteOnExit()).

Parameters:
rootDir - The directory to be deleted on exit.

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.