public class File extends java.lang.Object implements java.lang.Comparable<File>
Modifier and Type | Class and Description |
---|---|
static class |
File.WriteMode |
Constructor and Description |
---|
File(java.io.File file)
Create a File equivalent to the java.io.File provided
|
File(File parent,
java.lang.String child)
Construct a File representing the child
child of parent |
File(java.io.File parent,
java.lang.String child)
Construct a File representing the child
child of parent |
File(java.nio.file.Path path) |
File(java.nio.file.Path parent,
java.lang.String child)
Construct a File representing the child
child of parent |
File(java.lang.String path)
Construct a File representing the provided
path |
File(java.lang.String parent,
java.lang.String child)
Construct a File representing the child
child of parent |
File(java.net.URI path)
Convenience constructor equivalent to
new File(Paths.get(path)) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
absolutePath()
|
java.lang.String |
canonicalPath()
|
int |
compareTo(File that) |
boolean |
createDirectoriesIfNotExists() |
boolean |
createFileIfNotExists()
Try to create a new regular file at this path.
|
void |
delete()
This file will be deleted, with any failures being reported with an FSError
|
void |
delete(com.google.common.util.concurrent.RateLimiter rateLimiter)
This file will be deleted, obeying the provided rate limiter.
|
java.lang.Throwable |
delete(java.lang.Throwable accumulate)
This file will be deleted, and any exceptions encountered merged with
accumulate to the return value |
java.lang.Throwable |
delete(java.lang.Throwable accumulate,
com.google.common.util.concurrent.RateLimiter rateLimiter)
This file will be deleted, obeying the provided rate limiter.
|
void |
deleteIfExists()
This file will be deleted, with any failures being reported with an FSError
|
void |
deleteOnExit()
Try to delete the file on process exit.
|
void |
deleteRecursive()
Deletes all files and subdirectories under "dir".
|
void |
deleteRecursive(com.google.common.util.concurrent.RateLimiter rateLimiter)
Deletes all files and subdirectories under "dir".
|
void |
deleteRecursiveOnExit()
This file will be deleted on clean shutdown; if it is a directory, its entire contents
at the time of shutdown will be deleted
|
boolean |
equals(java.lang.Object obj) |
boolean |
exists() |
void |
forEach(java.util.function.Consumer<File> forEach) |
void |
forEachRecursive(java.util.function.Consumer<File> forEach) |
int |
hashCode() |
boolean |
isAbsolute() |
boolean |
isAncestorOf(File child) |
boolean |
isDirectory() |
boolean |
isExecutable() |
boolean |
isFile() |
boolean |
isReadable() |
boolean |
isWritable() |
long |
lastModified() |
long |
length() |
File[] |
list() |
File[] |
list(java.util.function.BiPredicate<File,java.lang.String> filter) |
File[] |
list(java.util.function.Predicate<File> filter) |
java.lang.String[] |
listNames() |
java.lang.String[] |
listNames(java.util.function.BiPredicate<File,java.lang.String> filter) |
java.lang.String[] |
listNamesUnchecked() |
java.lang.String[] |
listNamesUnchecked(java.util.function.BiPredicate<File,java.lang.String> filter) |
File[] |
listUnchecked() |
File[] |
listUnchecked(java.util.function.BiPredicate<File,java.lang.String> filter) |
File[] |
listUnchecked(java.util.function.Predicate<File> filter) |
void |
move(File to)
Atomically (if supported) rename/move this file to
to |
java.lang.String |
name() |
FileInputStreamPlus |
newInputStream() |
FileOutputStreamPlus |
newOutputStream(File.WriteMode mode) |
java.nio.channels.FileChannel |
newReadChannel() |
java.nio.channels.FileChannel |
newReadWriteChannel() |
java.nio.channels.FileChannel |
newWriteChannel(File.WriteMode mode) |
FileWriter |
newWriter(File.WriteMode mode) |
File |
parent() |
java.lang.String |
parentPath() |
java.lang.String |
path() |
static java.lang.String |
pathSeparator() |
File |
toAbsolute() |
File |
toCanonical() |
java.io.File |
toJavaIOFile() |
java.nio.file.Path |
toPath() |
java.lang.String |
toString() |
boolean |
tryCreateDirectories()
Try to create a directory at this path, creating any parent directories as necessary.
|
boolean |
tryCreateDirectory()
Try to create a directory at this path.
|
boolean |
tryDelete()
Try to delete the file, returning true iff it was deleted by us.
|
File[] |
tryList() |
File[] |
tryList(java.util.function.BiPredicate<File,java.lang.String> filter) |
File[] |
tryList(java.util.function.Predicate<File> filter) |
java.lang.String[] |
tryListNames() |
java.lang.String[] |
tryListNames(java.util.function.BiPredicate<File,java.lang.String> filter) |
<T extends java.lang.Throwable> |
tryListNames(java.util.function.BiPredicate<File,java.lang.String> filter,
net.openhft.chronicle.core.util.ThrowingFunction<java.io.IOException,java.lang.String[],T> orElse) |
<T extends java.lang.Throwable> |
tryListNames(net.openhft.chronicle.core.util.ThrowingFunction<java.io.IOException,java.lang.String[],T> orElse) |
boolean |
tryMove(File to)
Try to rename the file atomically, if the system supports it.
|
boolean |
trySetExecutable(boolean value)
Try to set if the path is executable by its owner
|
boolean |
trySetLastModified(long value)
Try to set the last modified time in millis of the path
|
boolean |
trySetReadable(boolean value)
Try to set if the path is readable by its owner
|
boolean |
trySetWritable(boolean value)
Try to set if the path is writable by its owner
|
static void |
unsafeSetFilesystem(java.nio.file.FileSystem fs) |
public File(java.lang.String parent, java.lang.String child)
child
of parent
public File(File parent, java.lang.String child)
child
of parent
public File(java.nio.file.Path parent, java.lang.String child)
child
of parent
public File(java.lang.String path)
path
public File(java.io.File file)
public File(java.io.File parent, java.lang.String child)
child
of parent
public File(java.net.URI path)
new File(Paths.get(path))
public File(java.nio.file.Path path)
path
- the path to wrappublic static java.lang.String pathSeparator()
public boolean tryDelete()
public java.lang.Throwable delete(java.lang.Throwable accumulate)
accumulate
to the return valuepublic java.lang.Throwable delete(java.lang.Throwable accumulate, com.google.common.util.concurrent.RateLimiter rateLimiter)
accumulate
to the return valuepublic void delete()
FSWriteError
- if cannot be deletedpublic void deleteIfExists()
FSWriteError
- if cannot be deletedpublic void delete(com.google.common.util.concurrent.RateLimiter rateLimiter)
FSWriteError
- if cannot be deletedpublic void deleteRecursive(com.google.common.util.concurrent.RateLimiter rateLimiter)
FSWriteError
- if any part of the tree cannot be deletedpublic void deleteRecursive()
FSWriteError
- if any part of the tree cannot be deletedpublic void deleteOnExit()
public void deleteRecursiveOnExit()
public boolean tryMove(File to)
public void move(File to)
to
FSWriteError
- if any part of the tree cannot be deletedpublic long length()
public long lastModified()
public boolean trySetLastModified(long value)
public boolean trySetReadable(boolean value)
public boolean trySetWritable(boolean value)
public boolean trySetExecutable(boolean value)
public boolean exists()
public boolean isDirectory()
public boolean isFile()
public boolean isReadable()
public boolean isWritable()
public boolean isExecutable()
public boolean createFileIfNotExists()
public boolean createDirectoriesIfNotExists()
public boolean tryCreateDirectory()
public boolean tryCreateDirectories()
public File parent()
public java.lang.String parentPath()
public boolean isAbsolute()
public boolean isAncestorOf(File child)
public File toAbsolute()
public java.lang.String absolutePath()
public File toCanonical()
public java.lang.String canonicalPath()
public java.lang.String name()
public void forEach(java.util.function.Consumer<File> forEach)
public void forEachRecursive(java.util.function.Consumer<File> forEach)
public java.lang.String[] tryListNames()
public java.lang.String[] tryListNames(java.util.function.BiPredicate<File,java.lang.String> filter)
public File[] tryList()
public File[] tryList(java.util.function.Predicate<File> filter)
public File[] tryList(java.util.function.BiPredicate<File,java.lang.String> filter)
public java.lang.String[] listNames() throws java.io.IOException
java.io.IOException
public java.lang.String[] listNames(java.util.function.BiPredicate<File,java.lang.String> filter) throws java.io.IOException
java.io.IOException
public File[] list() throws java.io.IOException
java.io.IOException
public File[] list(java.util.function.Predicate<File> filter) throws java.io.IOException
java.io.IOException
public File[] list(java.util.function.BiPredicate<File,java.lang.String> filter) throws java.io.IOException
java.io.IOException
public java.lang.String[] listNamesUnchecked() throws java.io.UncheckedIOException
java.io.UncheckedIOException
public java.lang.String[] listNamesUnchecked(java.util.function.BiPredicate<File,java.lang.String> filter) throws java.io.UncheckedIOException
java.io.UncheckedIOException
public File[] listUnchecked() throws java.io.UncheckedIOException
java.io.UncheckedIOException
public File[] listUnchecked(java.util.function.Predicate<File> filter) throws java.io.UncheckedIOException
java.io.UncheckedIOException
public File[] listUnchecked(java.util.function.BiPredicate<File,java.lang.String> filter) throws java.io.UncheckedIOException
java.io.UncheckedIOException
public <T extends java.lang.Throwable> java.lang.String[] tryListNames(net.openhft.chronicle.core.util.ThrowingFunction<java.io.IOException,java.lang.String[],T> orElse) throws T extends java.lang.Throwable
T extends java.lang.Throwable
public <T extends java.lang.Throwable> java.lang.String[] tryListNames(java.util.function.BiPredicate<File,java.lang.String> filter, net.openhft.chronicle.core.util.ThrowingFunction<java.io.IOException,java.lang.String[],T> orElse) throws T extends java.lang.Throwable
T extends java.lang.Throwable
public java.lang.String path()
public java.nio.file.Path toPath()
Path
of this filepublic java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int compareTo(File that)
compareTo
in interface java.lang.Comparable<File>
public java.io.File toJavaIOFile()
public java.nio.channels.FileChannel newReadChannel() throws java.nio.file.NoSuchFileException
FileChannel
for readingjava.nio.file.NoSuchFileException
public java.nio.channels.FileChannel newReadWriteChannel() throws java.nio.file.NoSuchFileException
FileChannel
for reading or writing; file will be created if it doesn't existjava.nio.file.NoSuchFileException
public java.nio.channels.FileChannel newWriteChannel(File.WriteMode mode) throws java.nio.file.NoSuchFileException
mode
- whether or not the channel appends to the underlying fileFileChannel
for writing; file will be created if it doesn't existjava.nio.file.NoSuchFileException
public FileWriter newWriter(File.WriteMode mode) throws java.io.IOException
java.io.IOException
public FileOutputStreamPlus newOutputStream(File.WriteMode mode) throws java.nio.file.NoSuchFileException
java.nio.file.NoSuchFileException
public FileInputStreamPlus newInputStream() throws java.nio.file.NoSuchFileException
java.nio.file.NoSuchFileException
public static void unsafeSetFilesystem(java.nio.file.FileSystem fs)
Copyright © 2009-2022 The Apache Software Foundation