public class Pathname
extends java.io.File
| Constructor and Description |
|---|
Pathname()
Creates a Pathname from the current directory (user.dir).
|
Pathname(java.io.File file)
Creates a Pathname from a file, using its relative -- not absolute or canonical -- path.
|
Pathname(java.lang.String pathName)
Creates a Pathname from a pathname.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
baseName()
Returns the base name (same as File#getName()).
|
java.util.List<Pathname> |
children()
Returns the immediate subelements of this pathname.
|
java.lang.String |
expandPath()
Returns the path, fully expanded, i.e., resolved within the file system.
|
java.lang.String |
extension()
Returns the extension, the segment trailing the final dot, or null if there is no dot in the
basename.
|
java.io.File |
file() |
static java.util.List<Pathname> |
findAll() |
static java.util.List<Pathname> |
glob(java.lang.String glob) |
Pathname |
parent()
Returns the parent directory as a pathname, as a relative path.
|
void |
printLines(java.util.List<java.lang.String> lines)
Writes the lines to the file.
|
byte[] |
readBytes()
Reads the file as an array of bytes.
|
java.util.List<java.lang.String> |
readLines()
Reads the file, returning a list of lines, which do not include end of line characters.
|
java.lang.String |
relativePath()
Returns the relative -- not absolute or canonical -- path.
|
java.lang.String |
rootName()
Returns the root name, which is the base name minus the (last) extension.
|
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toPath, toString, toURI, toURLpublic Pathname(java.io.File file)
public Pathname(java.lang.String pathName)
public Pathname()
public static java.util.List<Pathname> glob(java.lang.String glob)
public static java.util.List<Pathname> findAll()
public java.lang.String relativePath()
new Pathname("abc/def.txt").relativePath(); // == "abc/def.txt"
public java.lang.String baseName()
new Pathname("abc/def.txt").baseName(); // == "def.txt"
public java.lang.String extension()
new Pathname("abc/def.txt").extension(); // == "txt"
new Pathname("abc/def.tar.gz").extension(); // == "gz"
new Pathname("abc/def.").extension(); // == ""
new Pathname("abc/def").extension(); // == null
public java.lang.String rootName()
new Pathname("abc/def.txt").rootName(); // == "def"
new Pathname("abc/def.tar.gz").rootName(); // == "def.tar"
public java.io.File file()
public Pathname parent()
new Pathname("a")), then its "parent" directory is the current
directory (new Pathname(".") ). All parents continue to be relative, i.e., of
the form "../../..", even if that would resolve to the root (or above) of the current file
system.
new Pathname("a/b").parent(); // == "a"
new Pathname("b").parent(); // == "."
new Pathname("b").parent().parent(); // == ".."
new Pathname("b").parent().parent().parent(); // == "../.."
public java.lang.String expandPath()
public java.util.List<java.lang.String> readLines()
public byte[] readBytes()
public void printLines(java.util.List<java.lang.String> lines)
lines - the lines to printpublic java.util.List<Pathname> children()