|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.starteam.util.FileUtils
public final class FileUtils
Utility class for accessing file info.
| Method Summary | |
|---|---|
static long |
cmp(java.io.File f1,
java.io.File f2)
compare two files |
static java.lang.String |
condenseFilePaths(java.lang.String parentFolderPath,
java.lang.String childFolderPath,
boolean caseSensitive,
java.lang.String delimiter)
Compares the two paths and returns a relative path that represents the childFolderPath relative to parentFolderPath or
null if either of the paths passed in are already relative
or invalid, or if childFolderPath cannot be expressed
relative to parentFolderPath. |
static java.lang.String |
convertUnicodeEol(java.lang.String eol,
Encoding enc)
Convert an end-of-line string that is assumed to be in ANSI format, to one of our known and supported Unicode encodings. |
static java.lang.String |
fullyResolvedPath(java.lang.String name,
java.lang.String pathDelim)
returns a fully resolved path name |
static java.lang.String |
getAbsolutePath(java.lang.String path)
Returns the absolute pathname of the given pathname. |
static java.lang.String |
getCanonicalPathName(java.lang.String aPathName,
boolean bCaseSensitive)
returns the canonical path name |
static File.CharacterSet |
getCharacterSet(java.io.File f)
Determines the character set used by the given file. |
static Encoding |
getEncoding(byte[] buf,
int count)
Return the detected encoding for the byte buffer, or US_ASCII if we can't determine the encoding. |
static Encoding |
getEncoding(java.io.File f)
Return the detected encoding for the file |
static java.lang.String |
getName(java.lang.String path,
java.lang.String pathDelim)
Returns the name of the file represented by this pathname. |
static java.lang.String |
getParent(java.lang.String path,
java.lang.String pathDelim)
Returns the parent part of the given pathname, or null if
the name has no parent part. |
static boolean |
isAbsolute(java.lang.String path)
Tests if the given pathname is an absolute pathname. |
static boolean |
isBinary(java.io.File f)
Returns true if the file is considered to be binary. |
static boolean |
isUnicode(byte[] buf,
int count)
Returns true if the byte buffer indicates Unicode. |
static boolean |
isUnicode(java.io.File f)
Returns true if the file is considered to be Unicode. |
static boolean |
match(java.lang.String pattern,
java.lang.String file,
boolean caseSensitive)
match the file name to the pattern |
static boolean |
matchesAnyPattern(java.lang.String filename,
java.lang.String[] patterns,
boolean caseSensitive)
match a file name against a set of patterns |
static boolean |
matchPatternList(java.lang.String filename,
java.lang.String patternList,
boolean caseSensitive)
match a file name against a set of patterns |
static java.lang.String[] |
parsePatternList(java.lang.String patternList)
parse the given comma, space or semicolon delimited pattern list |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static java.lang.String convertUnicodeEol(java.lang.String eol,
Encoding enc)
eol - an end-of-line string in ANSI format. Should be one of "\r\n",
"\r", "\n".enc - the encoding to convert to. Must be one of UTF-16LE, UTF-16BE,
UTF-32LE or UTF-32BE to be converted.
public static File.CharacterSet getCharacterSet(java.io.File f)
throws java.io.IOException
f - File
java.io.IOException
public static Encoding getEncoding(byte[] buf,
int count)
buf - the byte buffer to check.count - length of the buffer.
public static Encoding getEncoding(java.io.File f)
throws java.io.IOException
f - A file whose encoding will be detected
java.io.IOException - if the file cannot be read
public static boolean isUnicode(byte[] buf,
int count)
buf - the byte buffer to check.count - length of the buffer.
public static boolean isBinary(java.io.File f)
throws java.io.IOException
f - the file to test
java.io.IOException
public static boolean isUnicode(java.io.File f)
throws java.io.IOException
f - the file to test
java.io.IOExceptionpublic static final boolean isAbsolute(java.lang.String path)
path - A pathname.
true if the pathname indicated by the
File object is an absolute pathname;
false otherwise.public static final java.lang.String getAbsolutePath(java.lang.String path)
The system property user.dir contains the current user
directory.
path - A pathname.
public static final java.lang.String getCanonicalPathName(java.lang.String aPathName,
boolean bCaseSensitive)
aPathName - the relative path namebCaseSensitive - true if case sensitive comparison
public static final java.lang.String fullyResolvedPath(java.lang.String name,
java.lang.String pathDelim)
name - the file namepathDelim - a path delimiter
public static long cmp(java.io.File f1,
java.io.File f2)
throws java.io.IOException
f1 - the first filef2 - the second file
java.io.IOException
public static boolean matchPatternList(java.lang.String filename,
java.lang.String patternList,
boolean caseSensitive)
filename - the file namepatternList - a list of patternscaseSensitive - true if case sensitive
public static boolean matchesAnyPattern(java.lang.String filename,
java.lang.String[] patterns,
boolean caseSensitive)
filename - the file namepatterns - a set of patternscaseSensitive - true if case sensitive
public static java.lang.String[] parsePatternList(java.lang.String patternList)
patternList - the pattern list
public static boolean match(java.lang.String pattern,
java.lang.String file,
boolean caseSensitive)
pattern - the patternfile - the file namecaseSensitive - true if case sensitive comaprison is required
public static final java.lang.String getParent(java.lang.String path,
java.lang.String pathDelim)
null if
the name has no parent part. The parent part is generally everything
leading up to the last occurrence of the separator character, although
the precise definition is system dependent. On UNIX, for example, the
parent part of "/usr/lib" is "/usr", whose
parent part is "/", which in turn has no parent. On Windows
platforms, the parent part of "c:\java" is
"c:\", which in turn has no parent.
path - A pathname.pathDelim - The path delimiter.
null if the name
has no parent part.FileUtils.getName(java.lang.String, java.lang.String)
public static final java.lang.String getName(java.lang.String path,
java.lang.String pathDelim)
path - A pathname.pathDelim - The path delimiter.
FileUtils.getParent(java.lang.String, java.lang.String)
public static final java.lang.String condenseFilePaths(java.lang.String parentFolderPath,
java.lang.String childFolderPath,
boolean caseSensitive,
java.lang.String delimiter)
childFolderPath relative to parentFolderPath or
null if either of the paths passed in are already relative
or invalid, or if childFolderPath cannot be expressed
relative to parentFolderPath.
Both c: and \folderName are invalid paths for the purposes of this
function. GetCanonicalPathName is called on both paths prior
to comparison. This function is essentially Windows-specific, but should
work correctly with at least Unix paths.
parentFolderPath - the parent pathchildFolderPath - the child pathcaseSensitive - true for a case sensistive comparisondelimiter - the inter path separator
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||