|
WebObjects 5.2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.webobjects.foundation.NSPathUtilities
This class provides static methods that are useful when working with paths. Specifically, it includes methods that extract particular path components, modify paths, and return special paths.
This class cannot be instantiated.
lastPathComponent(String path)
,
pathExtension(String path)
,
stringByAppendingPathComponent(String path, String component)
,
stringByAppendingPathExtension(String path, String extension)
,
stringByDeletingLastPathComponent(String path)
,
stringByDeletingPathExtension(String path)
,
stringByStandardizingPath(String path)
,
homeDirectory()
Constructor Summary | |
NSPathUtilities()
|
Method Summary | |
static boolean |
fileExistsAtPath(String path)
Deprecated. Use (new File(aString)).exists() |
static String |
homeDirectory()
Returns a String representing the home directory path of the user who executes the application. |
static String |
lastPathComponent(String path)
Returns the last path component of path . |
static String |
pathExtension(String path)
Returns a path's extension, if any (not including the extension divider). |
static boolean |
pathIsAbsolute(String path)
Deprecated. Use (new File(aString)).isAbsolute() . |
static boolean |
pathIsEqualToString(String path1,
String path2)
Deprecated. This method should not be used. |
static String |
stringByAppendingPathComponent(String path,
String component)
Returns a String made by appending path with component ,
preceded, if necessary, by a path separator. |
static String |
stringByAppendingPathExtension(String path,
String extension)
Returns a string made by appending to path an extension
separator, followed by extension . |
static String |
stringByDeletingLastPathComponent(String path)
Returns a string made by deleting the last path component from path , along with any final path separator. |
static String |
stringByDeletingPathExtension(String path)
Returns a String made by deleting the extension (if any, and only the last) from path . |
static String |
stringByNormalizingExistingPath(String path)
Returns a String containing the normalized path for an existing file. |
static String |
stringByStandardizingPath(String path)
Deprecated. This method should not be used. |
static URL |
URLWithPath(String path)
Deprecated. Use new URL("file://" + aString) . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public NSPathUtilities()
Method Detail |
public static URL URLWithPath(String path)
new URL("file://" + aString)
.
path
- the file system pathpath
URL
public static boolean fileExistsAtPath(String path)
(new File(aString)).exists()
path
- the file system pathtrue
if the file at path
existsFile
public static String homeDirectory()
public static String lastPathComponent(String path)
path
.The following table illustrates the effect of this method on a variety of paths:
path |
Result |
"/tmp/scratch.tiff " |
"scratch.tiff " |
"/tmp/scratch " |
"scratch " |
"/tmp/ " |
"tmp " |
"scratch " |
"scratch " |
"/ " |
"" (an empty string) |
path
- the file system pathpath
public static String pathExtension(String path)
The following table illustrates the effect of this method on a variety of paths:
path 's |
Result |
"/tmp/scratch.tiff " |
"tiff " |
"/tmp/scratch " |
"" (an empty string) |
"/tmp/ " |
"" (an empty string) |
"/tmp/scratch..tiff " |
"tiff " |
path
- the file system pathpath
public static boolean pathIsAbsolute(String path)
(new File(aString)).isAbsolute()
.
path
- the file system pathtrue
if path
is an absolute pathFile
public static boolean pathIsEqualToString(String path1, String path2)
path1
- a path string to compare for equalitypath2
- a path string to compare for equalitypublic static String stringByAppendingPathComponent(String path, String component)
path
with component
,
preceded, if necessary, by a path separator. The following table
illustrates the effect of this method on a variety of paths,
assuming that component
is supplied as
"scratch.tiff
":
path |
Result |
"/tmp " |
"/tmp/scratch.tiff " |
"/tmp/ " |
"/tmp/scratch.tiff " |
"/ " |
"/scratch.tiff " |
"" (an empty string) | "scratch.tiff " |
path
- string to which component
is addedcomponent
- string to add to path
component
to path
stringByAppendingPathExtension(java.lang.String, java.lang.String)
,
stringByDeletingLastPathComponent(java.lang.String)
public static String stringByAppendingPathExtension(String path, String extension)
path
an extension
separator, followed by extension
. Note that if path
ends with one or more slashes ("/"), these slashes are
deleted. The following table illustrates the effect of this method
on a variety of different paths, assuming that extension
is
supplied as "tiff"
:path |
Result |
"/tmp/scratch.old " |
"/tmp/scratch.old.tiff " |
"/tmp/scratch. " |
"/tmp/scratch..tiff " |
"/tmp/ " |
"/tmp.tiff " |
"scratch " |
"scratch.tiff " |
path
- the path to append the extension
toextension
- extension to be appended to path
path
an extension separator and
extension
public static String stringByDeletingLastPathComponent(String path)
path
, along with any final path separator. If
path
represents the root path, however, it's returned
unaltered. The following table illustrates the effect of this
method on a variety of paths:path |
Result |
"/tmp/scratch.tiff " |
"/tmp " |
"/tmp/lock/ " |
"/tmp " |
"/tmp/ " |
"/ " |
"/tmp " |
"/ " |
"/ " |
"/ " |
"scratch.tiff " |
"" (an empty string) |
path
- the path to processpath
stringByDeletingPathExtension(java.lang.String)
,
stringByAppendingPathComponent(java.lang.String, java.lang.String)
public static String stringByDeletingPathExtension(String path)
path
. Strips any trailing path
separator before checking for an extension. If path
represents the root path, however, it's returned unaltered. The
following table illustrates the effect of this method on a
variety of paths:path |
Result |
"/tmp/scratch.tiff " |
"/tmp/scratch " |
"/tmp/ " |
"/tmp " |
"scratch.bundle/ " |
"scratch " |
"scratch..tiff " |
"scratch. " |
".tiff " |
"" (an empty string) |
"/ " |
"/ " |
path
- the path to processpath
pathExtension(java.lang.String)
,
stringByDeletingLastPathComponent(java.lang.String)
public static String stringByNormalizingExistingPath(String path)
If the file does not exist, this method returns an empty string. The normalized
path is always absolute and corresponds to the canonical path returned
by the java.io.File.getCanonicalPath
method.
path
- path to be normalizedstringByStandardizingPath(java.lang.String)
public static String stringByStandardizingPath(String path)
path
- path string to standardize
|
Last updated Fri Feb 21 13:15:00 PST 2003. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |