public class FilePathDisk extends FilePath
Constructor and Description |
---|
FilePathDisk() |
Modifier and Type | Method and Description |
---|---|
boolean |
canWrite()
Check if the file is writable.
|
void |
createDirectory()
Create a directory (all required parent directories already exist).
|
boolean |
createFile()
Create a new file.
|
FilePath |
createTempFile(java.lang.String suffix,
boolean inTempDir)
Create a new temporary file.
|
void |
delete()
Delete a file or directory if it exists.
|
boolean |
exists()
Checks if a file exists.
|
static java.lang.String |
expandUserHomeDirectory(java.lang.String fileName)
Expand '~' to the user home directory.
|
FilePath |
getParent()
Get the parent directory of a file or directory.
|
FilePathDisk |
getPath(java.lang.String path)
Convert a file to a path.
|
java.lang.String |
getScheme()
Get the scheme (prefix) for this file provider.
|
boolean |
isAbsolute()
Check if the file name includes a path.
|
boolean |
isDirectory()
Check if it is a file or a directory.
|
boolean |
isRegularFile()
Check if it is a regular file.
|
long |
lastModified()
Get the last modified date of a file
|
void |
moveTo(FilePath newName,
boolean atomicReplace)
Rename a file if this is allowed.
|
java.util.List<FilePath> |
newDirectoryStream()
List the files and directories in the given directory.
|
java.io.InputStream |
newInputStream()
Create an input stream to read from the file.
|
java.io.OutputStream |
newOutputStream(boolean append)
Create an output stream to write into the file.
|
java.nio.channels.FileChannel |
open(java.lang.String mode)
Open a random access file object.
|
boolean |
setReadOnly()
Disable the ability to write.
|
long |
size()
Get the size of a file in bytes
|
FilePathDisk |
toRealPath()
Normalize a file name.
|
protected static java.lang.String |
translateFileName(java.lang.String fileName)
Translate the file name to the native format.
|
get, getName, newFileChannelOutputStream, register, toString, unregister, unwrap
public FilePathDisk getPath(java.lang.String path)
FilePath
java.nio.file.spi.FileSystemProvider.getPath
, but may
return an object even if the scheme doesn't match in case of the
default file provider.public long size()
FilePath
protected static java.lang.String translateFileName(java.lang.String fileName)
fileName
- the file namepublic static java.lang.String expandUserHomeDirectory(java.lang.String fileName)
fileName
- the file namepublic void moveTo(FilePath newName, boolean atomicReplace)
FilePath
public boolean createFile()
FilePath
createFile
in class FilePath
public boolean exists()
FilePath
public void delete()
FilePath
public java.util.List<FilePath> newDirectoryStream()
FilePath
newDirectoryStream
in class FilePath
public boolean canWrite()
FilePath
public boolean setReadOnly()
FilePath
setReadOnly
in class FilePath
public FilePathDisk toRealPath()
FilePath
toRealPath
in class FilePath
public FilePath getParent()
FilePath
public boolean isDirectory()
FilePath
isDirectory
in class FilePath
public boolean isRegularFile()
FilePath
isRegularFile
in class FilePath
public boolean isAbsolute()
FilePath
isAbsolute
in class FilePath
public long lastModified()
FilePath
lastModified
in class FilePath
public void createDirectory()
FilePath
createDirectory
in class FilePath
public java.io.OutputStream newOutputStream(boolean append) throws java.io.IOException
FilePath
newOutputStream
in class FilePath
append
- if true, the file will grow, if false, the file will be
truncated firstjava.io.IOException
- If an I/O error occurspublic java.io.InputStream newInputStream() throws java.io.IOException
FilePath
newInputStream
in class FilePath
java.io.IOException
- If an I/O error occurspublic java.nio.channels.FileChannel open(java.lang.String mode) throws java.io.IOException
FilePath
public java.lang.String getScheme()
FilePath
java.nio.file.spi.FileSystemProvider.getScheme
.public FilePath createTempFile(java.lang.String suffix, boolean inTempDir) throws java.io.IOException
FilePath
createTempFile
in class FilePath
suffix
- the suffixinTempDir
- if the file should be stored in the temporary directoryjava.io.IOException
- on failure