Class FileHelper

java.lang.Object
org.dbunit.util.FileHelper

public class FileHelper extends Object
Utility that provides some general methods for working with File objects.
Since:
2.3.0
Version:
$Revision$
Author:
gommma
  • Method Details

    • deleteDirectory

      public static void deleteDirectory(File directory, boolean failOnError)
      Recursively deletes the given directory
      Parameters:
      directory - The directory to delete
      failOnError - If an exception should be thrown in case the deletion did not work.
    • deleteDirectory

      public static boolean deleteDirectory(File directory)
      Recursively deletes the given directory
      Parameters:
      directory - The directory to delete
      Returns:
      true if the deletion was successfully.
    • createInputSource

      public static InputSource createInputSource(File file) throws MalformedURLException
      Creates an InputSource for the given file.
      Parameters:
      file - the file to create an InputSource for.
      Returns:
      the input source for the given file.
      Throws:
      MalformedURLException - if the file's path cannot be converted to a URL.
    • copyFile

      public static void copyFile(File srcFile, File destFile) throws IOException
      Copy file.
      Parameters:
      srcFile - the src file
      destFile - the dest file
      Throws:
      IOException - if copying the file fails.
    • readLines

      public static List readLines(File theFile) throws IOException
      Get a list of Strings from a given file. Uses the default encoding of the current platform.
      Parameters:
      theFile - the file to be read
      Returns:
      a list of Strings, each one representing one line from the given file
      Throws:
      IOException - if the file cannot be read.