|
WebObjects 5.2.3 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | 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() or fileExistsAtPathURL() |
static boolean |
fileExistsAtPathURL(URL pathURL)
|
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 |
stringByNormalizingPath(String path)
Returns a String containing the normalized path for a path string. |
static String |
stringByStandardizingPath(String path)
Deprecated. This method should not be used. |
static URL |
URLWithPath(String path)
Deprecated. Use new URL("file", "", path) . |
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", "", path)
.
path
- the file system path
path
URL
public static boolean fileExistsAtPath(String path)
(new File(aString)).exists()
or fileExistsAtPathURL()
path
- the file system path
true
if the file at path
existsFile
,
fileExistsAtPathURL(java.net.URL)
public static boolean fileExistsAtPathURL(URL pathURL)
pathURL
- the file URL
true
if the file at pathURL
exists.URL
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 path
path
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 " |
"/tmp/test.eomodeld/ " |
"eomodeld " |
path
- the file system path
path
public static boolean pathIsAbsolute(String path)
(new File(aString)).isAbsolute()
.
path
- the file system path
true
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 equality
public 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 process
path
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 process
path
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 normalized
stringByStandardizingPath(java.lang.String)
public static String stringByNormalizingPath(String path)
This is exactly like stringByNormalizingExistingPath, except that the
path does not have to reference an existing file.The normalized
path is always absolute and corresponds to the canonical path returned
by the java.io.File.getCanonicalPath
method.
path
- path to be normalized
stringByNormalizingExistingPath(java.lang.String)
public static String stringByStandardizingPath(String path)
path
- path string to standardize
|
Last updated Thu Oct 21 15:04:16 PDT 2004. | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |