org.rhq.core.pluginapi.util
Class FileUtils

java.lang.Object
  extended by org.rhq.core.pluginapi.util.FileUtils

public abstract class FileUtils
extends Object

A set of utilities for working with files and file paths.


Method Summary
static String findString(String filePath, String stringToFind)
           
static String getCanonicalPath(String path)
          Canonicalize the specified file path according to the current platform's rules: Condense multiple consecutive path separators into a single path separator.
static void purge(File fileOrDir, boolean deleteIt)
          The purpose of this method is to purge a directory of all of its contents, but it can also be used to simply delete a given file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

purge

public static void purge(File fileOrDir,
                         boolean deleteIt)
                  throws IOException
The purpose of this method is to purge a directory of all of its contents, but it can also be used to simply delete a given file. If dir is a directory, this method will attempt to delete all of its files and all of its subdirectories and their child files/subdirectories. dir itself will then be deleted, but only if deleteIt is true. If dir is not a directory, but rather a simple file, it will be deleted only if deleteIt is true. Note - This method does not protect against symbolic links and will follow them on UNIX/Linux.

If dir is null, this method does nothing.

Parameters:
fileOrDir - the file or directory to purge
deleteIt - if true, dir will be deleted after all of its contents are deleted
Throws:
IOException - if the purge fails

findString

public static String findString(String filePath,
                                String stringToFind)
                         throws IOException
Throws:
IOException

getCanonicalPath

public static String getCanonicalPath(String path)
Canonicalize the specified file path according to the current platform's rules:

Unlike File.getCanonicalPath(), this method does not resolve symlinks.

The path may or may not reference an existing file.

Parameters:
path - the file path to be canonicalized
Returns:
the canonicalized file path


Copyright © 2008-2009 RHQ Project Advisory Board (Red Hat, Inc.). All Rights Reserved.