Class Path
public class Path
{
// Methods
public static String append(String stPath1, String stPath2);
public static String getExtension(String stPath);
public static boolean hasExecExtensionType(String stPath);
public static boolean isRoot(String stPath);
public static boolean isValidFileChar (char ch);
public static String removeBeginEndQuotes(String stPath);
public static String removeTrailingSlash(String stPath);
public static String validateFilename (String origfilename,
char replch) throws IOException;
}
This class provides methods for checking and manipulating strings that represent paths.
public static String append(String stPath1, String stPath2);
Appends one path string to another. If necessary, a separator is inserted between the path strings.
Return Value:
Returns the string that consists of the second path appended to the first.
Parameter | Description |
stPath1
| The first path.
|
stPath2
| The second path, which will be appended to the first path.
|
public static String getExtension(String stPath);
Retrieves the extension of the filename. If there is no extension, this method returns null.
Return Value:
Returns the extension of the filename.
Parameter | Description |
stPath
| The path string.
|
public static boolean hasExecExtensionType(String stPath);
Determines whether the path string ends in .exe, .com, .bat, .pif, or .cmd.
Return Value:
Returns true if the path string ends in .exe, .com, .bat, .pif, or .cmd; otherwise, returns false.
Parameter | Description |
stPath
| The path string.
|
public static boolean isRoot(String stPath);
Determines whether the path string is a root path. For example, the following strings are root paths: "\", "c:\", "\\server\", and "\\server\share".
Return Value:
Returns true if the path string is a root path; otherwise, returns false.
Parameter | Description |
stPath
| The path string.
|
public static boolean isValidFileChar (char ch);
Determines whether a character can be used in a filename.
Return Value:
Returns true if the character can be used in a filename; otherwise, returns false.
Parameter | Description |
ch
| The character that is checked to see if it is valid in a filename.
|
public static String removeBeginEndQuotes(String stPath);
Removes leading and trailing quotes from the path string, if there are any.
Return Value:
Returns the path string with quotes removed.
Parameter | Description |
stPath
| The path string to remove quotes from.
|
public static String removeTrailingSlash(String stPath);
Removes a trailing backslash unless the path is a root path.
Return Value:
Returns the path string without the trailing backslash. If the path is a root path, it remains unchanged.
Parameter | Description |
stPath
| The path string.
|
public static String validateFilename (String origfilename,
char replch) throws IOException;
Checks a filename, and if it is not valid, attempts to correct it.
Return Value:
Returns a valid filename or the original filename, if it is already valid.
Parameter | Description |
origfilename
| The filename to check and correct.
|
replch
| The character to replace invalid characters with.
|
Exceptions:
IOException
if the filename cannot be corrected.