com.mancrd.ahah.commons.utils
Class FileUtils

java.lang.Object
  extended by com.mancrd.ahah.commons.utils.FileUtils

public final class FileUtils
extends Object

Author:
timmolter

Method Summary
static boolean copy(String srcPath, String destPath)
          Copies src file to dst file.
static boolean deleteFile(String fullyQualifiedFileName)
           
static Object deserialize(File file)
           
static boolean fileExists(String pFilePath)
          Checks if a file exists
static String[] getAllFileNames(String dirName)
          This method returns the names of all the files found in the given directory
static String[] getAllFileNames(String dirName, String regex)
          This method returns the names of all the files found in the given directory matching the given regular expression.
static File[] getAllFiles(String dirName)
          This method returns the Files found in the given directory
static File[] getAllFiles(String dirName, String regex)
          This method returns the files found in the given directory matching the given regular expression.
static void mkDirIfNotExists(String pFilePath)
          Makes a dir, if it doesn't already exist
static String readFileFromClasspathToString(String fileName)
          Given a File from the classpath, return the content of the file as a String
static String readFileToString(String filePath)
          Given a path to a File, return the content of the file as a String
static void serialize(Object object, String path)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

readFileToString

public static String readFileToString(String filePath)
Given a path to a File, return the content of the file as a String

Parameters:
file -
Returns:

readFileFromClasspathToString

public static String readFileFromClasspathToString(String fileName)
Given a File from the classpath, return the content of the file as a String

Parameters:
fileName -
Returns:

deserialize

public static Object deserialize(File file)

serialize

public static void serialize(Object object,
                             String path)

getAllFileNames

public static String[] getAllFileNames(String dirName)
This method returns the names of all the files found in the given directory

Parameters:
dirName - - ex. "./images/colors/original/" *make sure you have the '/' on the end
Returns:
String[] - an array of file names

getAllFiles

public static File[] getAllFiles(String dirName)
This method returns the Files found in the given directory

Parameters:
dirName - - ex. "./images/colors/original/" *make sure you have the '/' on the end
Returns:
File[] - an array of files

getAllFileNames

public static String[] getAllFileNames(String dirName,
                                       String regex)
This method returns the names of all the files found in the given directory matching the given regular expression.

Parameters:
dirName - - ex. "./images/colors/original/" *make sure you have the '/' on the end
regex - - ex. ".*.png"
Returns:
String[] - an array of file names

getAllFiles

public static File[] getAllFiles(String dirName,
                                 String regex)
This method returns the files found in the given directory matching the given regular expression.

Parameters:
dirName - - ex. "./images/colors/original/" *make sure you have the '/' on the end
regex - - ex. ".*.png"
Returns:
File[] - an array of files

copy

public static boolean copy(String srcPath,
                           String destPath)
Copies src file to dst file. If the dst file does not exist, it is created.

Parameters:
srcPath -
destPath -
Throws:
IOException

deleteFile

public static boolean deleteFile(String fullyQualifiedFileName)
Parameters:
fullyQualifiedFileName -
Returns:

fileExists

public static boolean fileExists(String pFilePath)
Checks if a file exists

Parameters:
pFilePath -
Returns:

mkDirIfNotExists

public static void mkDirIfNotExists(String pFilePath)
Makes a dir, if it doesn't already exist

Parameters:
pFilePath -


Copyright © 2013–2014 M. Alexander Nugent Consulting, Research and Devlopment. All rights reserved.