public class

FileUtil

extends Object
java.lang.Object
   ↳ com.microstrategy.utils.FileUtil

Summary

Public Constructors
FileUtil()
Public Methods
static void clear(String fileName)
Clears the contents of the file.
static void copy(String srcFileName, String desFileName)
Copies file srcFileName to another file desFileName.
static boolean deleteDir(File dir)
Deletes a directory (folder).
static String getFileExt(File f)
Returns file extension.
static boolean rename(String srcFileName, String desFileName)
Renames file srcFileName to desFileName.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public FileUtil ()

Public Methods

public static void clear (String fileName)

Clears the contents of the file.

Parameters
fileName name of file to be cleared
Throws
FileNotFoundException if file is not found
IOException if there is a problem during the clear operation

public static void copy (String srcFileName, String desFileName)

Copies file srcFileName to another file desFileName.

Parameters
srcFileName name of source file
desFileName name of destination file
Throws
FileNotFoundException if srcFileName cannot be found
IOException if there is a problem during the copy operation
IllegalArgumentException if either parameters are null

public static boolean deleteDir (File dir)

Deletes a directory (folder). Since a directory can only be deleted if it's empty, it first deletes the contents of the directory recursively, then calls delete on the folder itself.

Parameters
dir Directory to delete
Returns
  • boolean true only if the folder and its content were deleted successfully.

public static String getFileExt (File f)

Returns file extension. Always in lower case. Returns null if not found. File with names that begin with "." are not considered an extension (null returned). PRE: assumes object is a file (not a directory).

public static boolean rename (String srcFileName, String desFileName)

Renames file srcFileName to desFileName.

Parameters
srcFileName name of source file
desFileName new name
Returns
  • true if renaming was possible
See Also