PATH |
- Inherits from:
- Object
- Package:
- com.webobjects.foundation
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.
- Extracting path components
- lastPathComponent
- pathExtension
- Manipulating paths
- stringByAppendingPathComponent
- stringByAppendingPathExtension
- stringByDeletingLastPathComponent
- stringByDeletingPathExtension
- stringByNormalizingExistingPath
- stringByStandardizingPath
- Resolving special paths
- homeDirectory
- Deprecated methods
- URLWithPath
- fileExistsAtPath
- pathIsAbsolute
- pathIsEqualToString
public static boolean fileExistsAtPath(String aString)
(new File(aString)).exists()
instead.
public static String homeDirectory()
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) |
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 " |
public static boolean pathIsAbsolute(String aString)
(new File(aString)).isAbsolute()
instead.
public static boolean pathIsEqualToString( String string1, String string2)
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
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 " |
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
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
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
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 |
public static java.net.URL URLWithPath(String aString)
new URL("file://" + aString)
instead.
© 2001 Apple Computer, Inc. (Last Published April 17, 2001)