vc.util
Class FileSysUtility

java.lang.Object
  |
  +--vc.util.FileSysUtility

public class FileSysUtility
extends java.lang.Object

FileSysUtility is a utility for doing the file related operations using the java infrastructure for handling the file system and its components.


Field Summary
static int DirectoriesOnly
          A constant that flags that the current operation/state applies for directories only
static int FilesAndDirectories
          A constant that flags that the current operation/state applies for files both directories
static int FilesOnly
          A constant that flags that the current operation/state applies for files only
 
Constructor Summary
FileSysUtility()
           
 
Method Summary
static java.io.File createDirectory(java.lang.String pathName, boolean createIfDontExist)
          Cretes a java.io.File object for a corresponding directory.
static void getDirectoryChildren(java.io.File parentDirectory, int childrenType, java.util.Vector childrenVector)
          Method for getting the subdirectories and/or files under the specified directory according to the children type wanted.
static void getDirectoryChildren(java.lang.String parentDirectoryPath, int childrenType, java.util.Vector childrenVector)
          Method for getting the subdirectories and/or files under the specified directory according to the children type wanted.
static java.lang.String getFileContent(java.lang.String pathName)
          Method for getting the content of a file whose path is passed as a parameter.
static void saveFile(java.lang.String pathName, java.lang.String fileContent)
          Method for creating or recreating a file with the specified content.
static java.util.Vector selectFiles(int fileSelectionMode, java.awt.Component parent, java.lang.String currentDirectoryPath)
          Method for selecting the files and directories according to the options provided through the parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FilesOnly

public static final int FilesOnly
A constant that flags that the current operation/state applies for files only

DirectoriesOnly

public static final int DirectoriesOnly
A constant that flags that the current operation/state applies for directories only

FilesAndDirectories

public static final int FilesAndDirectories
A constant that flags that the current operation/state applies for files both directories
Constructor Detail

FileSysUtility

public FileSysUtility()
Method Detail

selectFiles

public static java.util.Vector selectFiles(int fileSelectionMode,
                                           java.awt.Component parent,
                                           java.lang.String currentDirectoryPath)
                                    throws java.lang.Throwable
Method for selecting the files and directories according to the options provided through the parameters. This will use JFileChooser, a swing component that gives a fancy GUI for selecting files and directories.
Parameters:
fileSelectionMode - to specify to select only file or directories only or both
parent - parent GUI component invoking this method
currentDirectoryPath - initial directory to be shown in the GUI for the selection of files/directories
Returns:
Returns the vector having the java.io.File objects representing file and/or directory objects selected

getFileContent

public static java.lang.String getFileContent(java.lang.String pathName)
                                       throws java.lang.Throwable
Method for getting the content of a file whose path is passed as a parameter.
Parameters:
pathName - path of the file whose content is to be returned
Returns:
Returns the content or data of the file specified

saveFile

public static void saveFile(java.lang.String pathName,
                            java.lang.String fileContent)
                     throws java.lang.Throwable
Method for creating or recreating a file with the specified content. If a file alredy exists then the file will be recreated with the new data so that the old content dont exist any more.
Parameters:
pathName - path of the file which has to be created or recreated with the content specified.
fileContent - content/data with which the file has to be created.

getDirectoryChildren

public static void getDirectoryChildren(java.io.File parentDirectory,
                                        int childrenType,
                                        java.util.Vector childrenVector)
Method for getting the subdirectories and/or files under the specified directory according to the children type wanted.
Parameters:
parentDirectory - the directory whose children are to be returned.
childrenType - flag specifying if to return only file, or only directories or both files and directories.
childrenVector - an out parameter to carry back the subdirectories and/or files found under the directory.

getDirectoryChildren

public static void getDirectoryChildren(java.lang.String parentDirectoryPath,
                                        int childrenType,
                                        java.util.Vector childrenVector)
Method for getting the subdirectories and/or files under the specified directory according to the children type wanted. Delegates to getDirectoryChildren() which takes the file instance as peremeter that represents a directory.
Parameters:
parentDirectory - path of the directory whose children are to be returned.
childrenType - flag specifying if to return only file, or only directories or both files and directories.
childrenVector - an out parameter to carry back the subdirectories and/or files found under the directory.

createDirectory

public static java.io.File createDirectory(java.lang.String pathName,
                                           boolean createIfDontExist)
Cretes a java.io.File object for a corresponding directory. If alredy a directory dont exist then creates a new directory. Then creates the File instance representing the directory
Parameters:
pathName - path of the directory for which a corresponding java.io.File object is to be created.
createIfDontExist - if true and directory doesnt exist then creates a new directory with the path specified.
Returns - a java.io.File object corresponding to the directory.