org.eclipse.emf.emfstore.internal.common.model.util
Class FileUtil

java.lang.Object
  extended by org.eclipse.emf.emfstore.internal.common.model.util.FileUtil

public final class FileUtil
extends Object

Helper class for file system operations.

Author:
wesendonk

Method Summary
static boolean areEqual(File file1, File file2)
          Compares the contents of two files.
static boolean areEqual(File file1, File file2, org.eclipse.core.runtime.IProgressMonitor monitor)
          Compares the contents of two files.
static void copyDirectory(File source, File destination)
          Copy a directory from source to target including its contained files and directories.
static void copyFile(File source, File destination)
          This method copies a single file.
static void copyFile(InputStream source, File destination)
          This method copies a single file and closes the given stream.
static void deleteDirectory(File file, boolean force)
          Deletes a directory.
static String getExtension(File file)
          Returns the extension of the given file.
static void zipFolder(File source, File destination)
          This method allows you to zip a folder.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

copyFile

public static void copyFile(File source,
                            File destination)
                     throws IOException
This method copies a single file.

Parameters:
source - the source
destination - the destination
Throws:
IOException - copy problem

copyFile

public static void copyFile(InputStream source,
                            File destination)
                     throws IOException
This method copies a single file and closes the given stream.

Parameters:
source - the source input stream
destination - the destination
Throws:
IOException - copy problem

copyDirectory

public static void copyDirectory(File source,
                                 File destination)
                          throws IOException
Copy a directory from source to target including its contained files and directories.

Parameters:
source - directory
destination - directory
Throws:
IOException - on a IO problem during copy

zipFolder

public static void zipFolder(File source,
                             File destination)
                      throws IOException
This method allows you to zip a folder. *UNDER CONSTRUCTION*

Parameters:
source - folder to zip
destination - target zip file
Throws:
IOException - in case of failure

areEqual

public static boolean areEqual(File file1,
                               File file2)
Compares the contents of two files.

Parameters:
file1 - the first file
file2 - the second file
Returns:
true, if the content of both files is equal, false otherwise

areEqual

public static boolean areEqual(File file1,
                               File file2,
                               org.eclipse.core.runtime.IProgressMonitor monitor)
Compares the contents of two files.

Parameters:
file1 - the first file
file2 - the second file
monitor - a progress monitor that may be used to indicate the progress of the equality check
Returns:
true, if the content of both files is equal, false otherwise

deleteDirectory

public static void deleteDirectory(File file,
                                   boolean force)
                            throws IOException
Deletes a directory.

Parameters:
file - the directory
force - true if delete should try to delete forcefully including retries, this may be slow.
Throws:
IOException - if delete fails

getExtension

public static String getExtension(File file)
Returns the extension of the given file.

Parameters:
file - the file whose extension should be determined
Returns:
the file extension, if any, otherwise empty string


Copyright © 2015. All Rights Reserved.