PATH |
NSPathUtilities
- Inherits from:
- Object
- Package:
- com.webobjects.foundation
Class Description
This class provides static methods that are useful when working with paths. Specifically, it includes methods that extract particular path components ( lastPathComponent and pathExtension), modify paths ( stringByAppendingPathComponent, stringByAppendingPathExtension, stringByDeletingLastPathComponent, stringByDeletingPathExtension, and stringByStandardizingPath), and return special paths ( homeDirectory).
The NSPathUtilities class cannot be instantiated.
Method Types
- Extracting path components
- lastPathComponent
- pathExtension
- Manipulating paths
- stringByAppendingPathComponent
- stringByAppendingPathExtension
- stringByDeletingLastPathComponent
- stringByDeletingPathExtension
- stringByNormalizingExistingPath
- stringByStandardizingPath
- Resolving special paths
- homeDirectory
- Deprecated methods
- URLWithPath
- fileExistsAtPath
- pathIsAbsolute
- pathIsEqualToString
Static Methods
fileExistsAtPath
public static boolean fileExistsAtPath(String aString)
(new File(aString)).exists()
instead.
homeDirectory
public static String homeDirectory()
lastPathComponent
public static String lastPathComponent(String aString)
aString's Value | String Returned |
"/tmp/scratch.tiff " |
"scratch.tiff " |
"/tmp/scratch " |
"scratch " |
"/tmp/ " |
"tmp " |
"scratch " |
"scratch " |
"/ " |
"" (an empty string) |
pathExtension
public static String pathExtension(String aString)
aString's Value | String Returned |
"/tmp/scratch.tiff " |
"tiff " |
"/tmp/scratch " |
"" (an empty string) |
"/tmp/ " |
"" (an empty string) |
"/tmp/scratch..tiff " |
"tiff " |
pathIsAbsolute
public static boolean pathIsAbsolute(String aString)
(new File(aString)).isAbsolute()
instead.
pathIsEqualToString
public static boolean pathIsEqualToString( String string1, String string2)
stringByAppendingPathComponent
public static String stringByAppendingPathComponent( String string1, String string2)
scratch.tiff
":string1's Value | Resulting String |
"/tmp " |
"/tmp/scratch.tiff " |
"/tmp/ " |
"/tmp/scratch.tiff " |
"/ " |
"/scratch.tiff " |
"" (an empty string) | "scratch.tiff " |
See Also: stringByAppendingPathExtension, stringByDeletingLastPathComponent
stringByAppendingPathExtension
public static String stringByAppendingPathExtension( String string1, String string2)
"tiff"
:string1's Value | Resulting String |
"/tmp/scratch.old " |
"/tmp/scratch.old.tiff " |
"/tmp/scratch. " |
"/tmp/scratch..tiff " |
"/tmp/ " |
"/tmp.tiff " |
"scratch " |
"scratch.tiff " |
stringByDeletingLastPathComponent
public static String stringByDeletingLastPathComponent(String aString)
aString's Value | Resulting String |
"/tmp/scratch.tiff " |
"/tmp " |
"/tmp/lock/ " |
"/tmp " |
"/tmp/ " |
"/ " |
"/tmp " |
"/ " |
"/ " |
"/ " |
"scratch.tiff " |
"" (an empty string) |
See Also: stringByDeletingPathExtension, stringByAppendingPathComponent
stringByDeletingPathExtension
public static String stringByDeletingPathExtension(String aString)
aString's Value | Resulting String |
"/tmp/scratch.tiff " |
"/tmp/scratch " |
"/tmp/ " |
"/tmp " |
"scratch.bundle/ " |
"scratch " |
"scratch..tiff " |
"scratch. " |
".tiff " |
"" (an empty string) |
"/ " |
"/ " |
See Also: pathExtension, stringByDeletingLastPathComponent
stringByNormalizingExistingPath
public static String stringByNormalizingExistingPath(String aString)
null
. The normalized path is always absolute and corresponds to the canonical path returned by the java.io.File.getCanonicalPath method. See Sun's documentation for this method for more information.
See Also: stringByStandardizingPath
stringByStandardizingPath
public static String stringByStandardizingPath(String aString)
aString's Value | Resulting String |
"~/scratch.tiff " |
"/Local/Users/guest/scratch.tiff " |
"~ " |
"/Local/Users/guest " |
"~/.. " |
"/Local/Users/ " |
"guest/../john/scratch.tiff " |
"john/scratch.tiff " |
"../scratch.tiff " |
throws IllegalArgumentException |
URLWithPath
public static java.net.URL URLWithPath(String aString)
new URL("file://" + aString)
instead.
© 2001 Apple Computer, Inc. (Last Published April 17, 2001)