audiojury.proxy
Class PluginUtil

java.lang.Object
  |
  +--audiojury.proxy.PluginUtil

public class PluginUtil
extends java.lang.Object

Contains a number of helper methods that carry out common file operations.

See Also:
ProjectStoragePlugin, ResultPlugin

Method Summary
static void copyFiles(java.io.File src, java.io.File dest)
          Copies a source file or directory to another destination.
static boolean deleteDir(java.io.File dir)
          Recursively deletes a directory.
static boolean existsFile(java.lang.String path_and_file)
          Checks if a certain file exists.
static java.io.File[] listDirectory(java.lang.String dir_path)
          Lists the contents of a directory.
static java.lang.Object readObject(java.lang.String path_and_file)
          Reads an object from file.
static void saveToTextFile(java.lang.String path_and_file, java.lang.String data)
          Saves a text string to a file.
static void writeObject(java.lang.String path_and_file, java.lang.Object object)
          Writes an object to file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

saveToTextFile

public static void saveToTextFile(java.lang.String path_and_file,
                                  java.lang.String data)
                           throws java.io.IOException
Saves a text string to a file.

Parameters:
path_and_file - The complete path to the output file.
data - The string to write.
Throws:
java.io.IOException - if there was an unhandled IO error during the operation.

existsFile

public static boolean existsFile(java.lang.String path_and_file)
Checks if a certain file exists.

Parameters:
path_and_file - Full path and filename of the file to check.
Returns:
True if file existed, false otherwise.

listDirectory

public static java.io.File[] listDirectory(java.lang.String dir_path)
Lists the contents of a directory. Both files and directories.

Parameters:
dir_path - Path to a directory to list.
Returns:
The files and directories within the directory.

readObject

public static java.lang.Object readObject(java.lang.String path_and_file)
                                   throws java.io.IOException,
                                          java.lang.ClassNotFoundException
Reads an object from file.

Parameters:
path_and_file - Full path and filename to the serialized object.
Returns:
The object.
Throws:
java.io.IOException - if there was an unhandled IO error during the operation.
java.lang.ClassNotFoundException - if the class of a serialized object cannot be found.

writeObject

public static void writeObject(java.lang.String path_and_file,
                               java.lang.Object object)
                        throws java.io.IOException
Writes an object to file.

Parameters:
path_and_file - Full path and filename where to save the object.
object - An object to serialize.
Throws:
java.io.IOException - if there was an unhandled IO error during the operation.

deleteDir

public static boolean deleteDir(java.io.File dir)
Recursively deletes a directory.

Parameters:
dir - The directory to delete.
Returns:
True if succeeded to delete the directory including all files and subdirectories, false otherwise.

copyFiles

public static void copyFiles(java.io.File src,
                             java.io.File dest)
                      throws java.io.IOException
Copies a source file or directory to another destination. Contents of directories are copied recursively.

Parameters:
src - The file or directory to copy.
dest - The destination directory.
Throws:
java.io.IOException - if there was an unhandled IO error during the operation.