|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bluestream.sys.util.FileUtil
FileUtil: The primary purpose here is to maintain a process wide concept of the Current Working Directory (or CWD). NOTE: This class currently does not make use of the System object as there are known bugs in that package. At some point in the future, when System is known to provide reliable results, this modules implementation could be changed to rely on System.
| Constructor Summary | |
FileUtil()
|
|
| Method Summary | |
static void |
allowFileRead(String filename)
|
static void |
appendFile(String fileName,
String output)
append to a file |
static void |
buildTree(String path,
boolean fContainsFN)
Build a tree on the file system |
static boolean |
compareTextFiles(String fn1,
String fn2,
int flags,
FlexStringBuffer fsbErrs)
|
static void |
copyFile(File srcFile,
File destFile)
Copy the contents of srcFile to destFile. |
static void |
copyFile(String fileSrc,
String fileDest)
|
static File |
createFileInSpecifiedDir(File workingDir,
String createdDirName,
String createdFileName)
This method creates a directory called 'createdDirName' inside the 'workingDir' directory, and then creates a file called 'createdFileName' located inside the newly created directory. |
static boolean |
deleteFile(File fileToDelete)
Checks for the existence of the passed in File, and deletes the file if it does exist. |
static String |
getCWD()
return the CWD string |
static String |
getExt(String fullName)
get the extension of the file name (after the dot)not including dot. |
static String |
getName(String fullName)
Strip the file name from the path |
static String |
getPath(String fullStr)
Strip the file name from the path |
static String |
getPrimary(String name)
Get the primary part of a file name. |
static String |
getVolume(String fullName)
Get the volume from the fullname. |
static String |
readAsEncodedXml(File file)
|
static String |
readAsEncodedXml(String fileName)
|
static byte[] |
readBinary(File file)
Reads a file into a byte[] without changing the encoding. |
static void |
readBinary(File file,
byte[] b)
Read binary file. |
static String |
readFile(File file)
|
static String |
readFile(String fileName)
read a file into a string. |
static String |
readFileNoComments(File file)
Read a file and strip out single line comments that begin with double slash in the first position. |
static String |
readRecent(File file,
int recentLineCount)
Reads last recentLineCount number of lines from the file into a string. |
static void |
removeDir(File dir)
recursively removes a directory |
static void |
setCWD(String cwd)
assign a new directory to be the CWD |
static void |
setLinuxFilePermission(String permission)
Sets a file permission for Linux, Unix and Mac. |
static void |
stripCR(File f)
strips all CR characters from the TEXT file specified. |
static String |
stripVolume(String fullName)
Strip the volume from the fullname. |
static void |
writeAsEncodedXml(String filename,
String content)
|
static void |
writeBinary(File file,
byte[] b)
Write binary file. |
static void |
writeFile(String fileName,
String output)
Simple - write string to a file. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public FileUtil()
| Method Detail |
public static void setCWD(String cwd)
public static String getCWD()
public static String getPrimary(String name)
public static String getPath(String fullStr)
public static String getName(String fullName)
public static String getExt(String fullName)
public static String getVolume(String fullName)
public static String stripVolume(String fullName)
public static String readFile(String fileName)
public static String readFile(File file)
public static String readFileNoComments(File file)
throws IOException
IOException
public static String readRecent(File file,
int recentLineCount)
throws IOException
file - - file to be read.recentLineCount - - number of lines to be read.
IOException
public static void writeFile(String fileName,
String output)
public static void appendFile(String fileName,
String output)
public static void removeDir(File dir)
public static void stripCR(File f)
throws IOException
IOException
public static void copyFile(String fileSrc,
String fileDest)
throws IOException
IOException
public static void copyFile(File srcFile,
File destFile)
throws IOException
IOException
public static void readBinary(File file,
byte[] b)
throws IOException,
FileNotFoundException
IOException
FileNotFoundExceptionpublic static byte[] readBinary(File file)
file - The file to read.
BaseException - Thrown if an error occurs while reading
the file.
public static void writeBinary(File file,
byte[] b)
throws IOException,
FileNotFoundException
IOException
FileNotFoundException
public static void writeAsEncodedXml(String filename,
String content)
throws Exception
Exceptionpublic static String readAsEncodedXml(String fileName)
public static String readAsEncodedXml(File file)
public static boolean compareTextFiles(String fn1,
String fn2,
int flags,
FlexStringBuffer fsbErrs)
fn1 - first reader (Candidate)fn2 - second reader (Reference)flags - CompareUtil.kContinueOnErr, or 0 for no flags.
public static void allowFileRead(String filename)
public static void setLinuxFilePermission(String permission)
permission - a string representing the permission that would
be entered on a commandline, eg "chmod 777 runServer.sh"
public static void buildTree(String path,
boolean fContainsFN)
path - full path - usually without file name eg: c:/a/b. Must have volume name.fContainsFN - Whether a filename is contained in path parameter.
public static File createFileInSpecifiedDir(File workingDir,
String createdDirName,
String createdFileName)
workingDir - File object for the current working directory.createdDirName - String name of the containing directory to be created
in the current working directory.createdFileName - String name of the new file to be created.
public static boolean deleteFile(File fileToDelete)
fileToDelete - File to be deleted.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||