public class File
extends java.lang.Object
Constructor and Description |
---|
File() |
Modifier and Type | Method and Description |
---|---|
static long |
copy(java.lang.String source,
java.lang.String destination)
Copy a file from one location to another.
|
static boolean |
delete(java.lang.String source)
Remove a file from the file system
|
static boolean |
exists(java.lang.String pathname)
Deterines if a file exists.
|
static java.lang.String |
getBaseName(java.lang.String pathname)
Extract the base name of the file from a pathname.
|
static java.lang.String |
getExtension(java.lang.String pathname)
Extract the extension of the file from a pathname.
|
static java.lang.String |
getMD5(java.lang.String pathname)
Return the MD5 digest for a file.
|
static java.lang.String |
getModificationDate(java.lang.String pathname)
Return the modification date in ISO8601 format for a file.
|
static java.lang.String |
getName(java.lang.String pathname)
Extract the name of the file from a pathname.
|
static java.lang.String |
getParent(java.lang.String pathname)
Extract the parent of the file from a pathname.
|
static java.lang.String |
getSHA1(java.lang.String pathname)
Return the SHA-1 digest for a file.
|
static java.lang.String |
getSHA256(java.lang.String pathname)
Return the SHA-256 digest for a file.
|
static java.lang.String |
getSHA512(java.lang.String pathname)
Return the SHA-512 digest for a file.
|
static long |
getSize(java.lang.String pathname)
Return the size of the file in bytes.
|
static boolean |
isDirectory(java.lang.String pathname)
Determines if a given pathname is to a directory.
|
static boolean |
isFile(java.lang.String pathname)
Determines if a given pathname is to a file.
|
static boolean |
mkdirs(java.lang.String pathname)
Create all directories leading to a file with a given pathname.
|
static boolean |
rename(java.lang.String source,
java.lang.String destination)
Rename a file.
|
static boolean |
setOwner(java.lang.String pathname,
java.lang.String user,
java.lang.String group)
Set the owner and group for a file.
|
public static long copy(java.lang.String source, java.lang.String destination) throws java.lang.NullPointerException, java.io.IOException, java.lang.SecurityException
source
- the name of the source file.destination
- the name of the file to copy the source file to.java.lang.NullPointerException
java.io.IOException
java.lang.SecurityException
public static boolean delete(java.lang.String source)
source
- the name of the source file.true
if the delete is successful.
false
otherwise.public static boolean rename(java.lang.String source, java.lang.String destination) throws java.lang.NullPointerException, java.lang.SecurityException, java.io.IOException
source
- the name of the source file.true
if the rename is successful.
false
otherwise.java.io.IOException
- If an I/O error occurs, which is possible because
the construction of the canonical pathname may require file system queriesjava.lang.NullPointerException
- If the either pathname argument is nulljava.lang.SecurityException
- If a security manager exists and its
SecurityManager.checkWrite(java.lang.String) method denies
write access to either the old or new pathnamespublic static boolean mkdirs(java.lang.String pathname)
pathname
- the path and filename for a file.public static boolean isDirectory(java.lang.String pathname)
pathname
- the name of the file system object.true
if the pathname points to a directory.
false
otherwise.public static boolean isFile(java.lang.String pathname)
pathname
- the name of the filesystem object.true
if the pathname points to a directory.
false
otherwise.public static java.lang.String getName(java.lang.String pathname)
pathname
- the name of the file system object.public static java.lang.String getParent(java.lang.String pathname)
pathname
- the name of the filesystem object.public static java.lang.String getBaseName(java.lang.String pathname)
pathname
- the name of the file system object.public static java.lang.String getExtension(java.lang.String pathname)
pathname
- the name of the file system object.public static boolean setOwner(java.lang.String pathname, java.lang.String user, java.lang.String group)
pathname
- the name of the file system object.user
- the user name in the system.group
- the group name in the systempublic static long getSize(java.lang.String pathname)
pathname
- the name of the file system object.public static boolean exists(java.lang.String pathname)
pathname
- the name of the file system object.public static java.lang.String getModificationDate(java.lang.String pathname)
pathname
- the name of the file system object.public static java.lang.String getMD5(java.lang.String pathname)
pathname
- the name of the filesystem object.public static java.lang.String getSHA1(java.lang.String pathname)
pathname
- the name of the filesystem object.public static java.lang.String getSHA256(java.lang.String pathname)
pathname
- the name of the filesystem object.public static java.lang.String getSHA512(java.lang.String pathname)
pathname
- the name of the filesystem object.Copyright © 2008-2018 Regents University of California. All Rights Reserved.