|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.File tribble.io.Filename
public class Filename
Enhanced abstract pathname (filename).
This class extends the standard java.io.File class, adding some useful methods.
Objects of this class type can be used anywhere that an object of type java.io.File can be used.
Note that Filename objects are immutable, i.e., their contents cannot be modified, in the same way that java.io.File objects are immutable.
Copyright
©2003 by David R. Tribble, all rights reserved.
Permission is granted to freely use and distribute this source code
provided that the original copyright and authorship notices remain
intact.
Field Summary | |
---|---|
(package private) static java.lang.String |
REV
Revision information. |
Fields inherited from class java.io.File |
---|
pathSeparator, pathSeparatorChar, separator, separatorChar |
Constructor Summary | |
---|---|
Filename(java.io.File path)
Create a new filename from an abstract pathname. |
|
Filename(java.io.File parent,
java.lang.String child)
Create a new filename from a parent abstract pathname and a child pathname string. |
|
Filename(java.lang.String path)
Constructor. |
|
Filename(java.lang.String parent,
java.lang.String child)
Create a new filename from a parent abstract pathname and a child pathname string. |
|
Filename(java.net.URI uri)
Create a new filename by converting the given "file:" URI into an abstract pathname. |
Method Summary | |
---|---|
java.util.Date |
getLastModified()
Retrieve the last modification date of this filename. |
java.lang.String |
getSuffix()
Extract the suffix (extension) of this pathname. |
static java.lang.String |
getSuffix(java.io.File path)
Extract the suffix (extension) of a filename. |
void |
setLastModified(java.util.Date time)
Change the last modification date of this filename. |
Methods inherited from class java.io.File |
---|
canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getName, getParent, getParentFile, getPath, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setLastModified, setReadOnly, toString, toURI, toURL |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
static final java.lang.String REV
Constructor Detail |
---|
public Filename(java.lang.String path)
path
- A pathname string.
java.lang.NullPointerException
- (unchecked)
Thrown if path is null.public Filename(java.lang.String parent, java.lang.String child)
If parent is null then the new filename is created as if by invoking the single-argument Filename constructor on the given child pathname string.
Otherwise the parent pathname string is taken to denote a directory, and the child pathname string is taken to denote either a directory or a file. If child is absolute then it is converted into a relative pathname in a system-dependent way. If parent is empty ("") then the new filename is created by converting child into an abstract pathname and resolving the result against a system-dependent default directory. Otherwise each pathname string is converted into an abstract pathname and the child abstract pathname is resolved against the parent.
parent
- The parent pathname string.child
- The child pathname string.
java.lang.NullPointerException
- (unchecked)
Thrown if child is null.public Filename(java.io.File parent, java.lang.String child)
If parent is null then the new filename is created as if by invoking the single-argument Filename constructor on the given child pathname string.
Otherwise the parent abstract pathname is taken to denote a directory, and the child pathname string is taken to denote either a directory or a file. If child is absolute then it is converted into a relative pathname in a system-dependent way. If parent is the empty abstract pathname then the new filename is created by converting child into an abstract pathname and resolving the result against a system-dependent default directory. Otherwise each pathname string is converted into an abstract pathname and the child abstract pathname is resolved against the parent.
parent
- The parent abstract pathname.child
- The child pathname string.
java.lang.NullPointerException
- (unchecked)
Thrown if child is null.public Filename(java.io.File path)
Note that this is a convenience method for converting a java.io.File object into a Filename.
path
- An abstract pathname.public Filename(java.net.URI uri)
The exact form of a "file:" URI is system-dependent, hence the transformation performed by this constructor is also system-dependent.
For a given abstract pathname f it is guaranteed that
new Filename(f.toURI()).equals(f)is true so long as the original abstract pathname, the URI, and the new abstract pathname are all created in (possibly different invocations of) the same Java virtual machine. This relationship typically does not hold, however, when a "file:" URI that is created in a virtual machine on one operating system is converted into an abstract pathname in a virtual machine on a different operating system.
uri
- An absolute, hierarchical URI with a scheme equal to "file", a
non-empty path component, and undefined authority, query, and fragment
components.
java.lang.NullPointerException
- (unchecked)
Thrown if uri is null .
java.lang.IllegalArgumentException
- (unchecked)
Thrown if the preconditions on the parameter do not hold.Method Detail |
---|
public static java.lang.String getSuffix(java.io.File path)
path
- An abstract pathname.
"foo" => "" (empty suffix) "foo." => "." "foo.txt" => ".txt" "foo.x.h" => ".h" "/my/files/abc..pl" => ".pl"
public java.lang.String getSuffix()
"foo" => "" (empty suffix) "foo." => "." "foo.txt" => ".txt" "foo.x.h" => ".h" "/my/files/abc..pl" => ".pl"
public java.util.Date getLastModified()
File.lastModified()
public void setLastModified(java.util.Date time)
time
- A date.File.setLastModified(long)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |