|
WebObjects 5.4.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.webobjects.foundation.NSPathUtilities
public class 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.
NSPathUtilities.lastPathComponent(String path)
,
NSPathUtilities.pathExtension(String path)
,
NSPathUtilities.stringByAppendingPathComponent(String path, String component)
,
NSPathUtilities.stringByAppendingPathExtension(String path, String extension)
,
NSPathUtilities.stringByDeletingLastPathComponent(String path)
,
NSPathUtilities.stringByDeletingPathExtension(String path)
,
NSPathUtilities.stringByStandardizingPath(String path)
,
NSPathUtilities.homeDirectory()
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 |
Method Detail |
---|
public static String homeDirectory()
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 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 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
NSPathUtilities.stringByDeletingPathExtension(java.lang.String)
,
NSPathUtilities.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
NSPathUtilities.pathExtension(java.lang.String)
,
NSPathUtilities.stringByDeletingLastPathComponent(java.lang.String)
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
NSPathUtilities.stringByAppendingPathExtension(java.lang.String, java.lang.String)
,
NSPathUtilities.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 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
NSPathUtilities.stringByStandardizingPath(java.lang.String)
@Deprecated public static String stringByStandardizingPath(String path)
path
- path string to standardize
@Deprecated public static boolean pathIsEqualToString(String path1, String path2)
path1
- a path string to compare for equalitypath2
- a path string to compare for equality
@Deprecated public static boolean pathIsAbsolute(String path)
(new File(aString)).isAbsolute()
.
path
- the file system path
true
if path
is an absolute pathFile
@Deprecated public static boolean fileExistsAtPath(String path)
(new File(aString)).exists()
or fileExistsAtPathURL()
path
- the file system path
true
if the file at path
existsFile
,
NSPathUtilities.fileExistsAtPathURL(java.net.URL)
public static boolean fileExistsAtPathURL(URL pathURL)
pathURL
- the file URL
true
if the file at pathURL
exists.URL
@Deprecated public static URL URLWithPath(String path)
new URL("file", "", path)
.
path
- the file system path
path
URL
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
NSPathUtilities.stringByNormalizingExistingPath(java.lang.String)
|
Last updated June 2008 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |