public class File extends Object
Constructor and Description |
---|
File() |
Modifier and Type | Method and Description |
---|---|
static long |
copy(String source,
String destination)
Copy a file from one location to another.
|
static boolean |
delete(String source)
Remove a file from the file system
|
static boolean |
exists(String pathname)
Deterines if a file exists.
|
static String |
getBaseName(String pathname)
Extract the base name of the file from a pathname.
|
static String |
getExtension(String pathname)
Extract the extension of the file from a pathname.
|
static String |
getMD5(String pathname)
Return the MD5 digest for a file.
|
static String |
getName(String pathname)
Extract the name of the file from a pathname.
|
static String |
getParent(String pathname)
Extract the parent of the file from a pathname.
|
static String |
getSHA1(String pathname)
Return the SHA-1 digest for a file.
|
static String |
getSHA256(String pathname)
Return the SHA-256 digest for a file.
|
static String |
getSHA512(String pathname)
Return the SHA-512 digest for a file.
|
static long |
getSize(String pathname)
Return the size of the file in bytes.
|
static boolean |
isDirectory(String pathname)
Determines if a given pathname is to a directory.
|
static boolean |
isFile(String pathname)
Determines if a given pathname is to a file.
|
static boolean |
rename(String source,
String destination)
Rename a file.
|
static boolean |
setOwner(String pathname,
String user,
String group)
Set the owner and group for a file.
|
public static long copy(String source, String destination) throws NullPointerException, IOException, SecurityException
source
- the name of the source file.destination
- the name of the file to copy the source file to.NullPointerException
IOException
SecurityException
public static boolean delete(String source)
source
- the name of the source file.true
if the delete is successful.
false
otherwise.public static boolean rename(String source, String destination) throws NullPointerException, SecurityException, IOException
source
- the name of the source file.true
if the rename is successful.
false
otherwise.IOException
- If an I/O error occurs, which is possible because
the construction of the canonical pathname may require file system queriesNullPointerException
- If the either pathname argument is nullSecurityException
- 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 isDirectory(String pathname)
pathname
- the name of the file system object.true
if the pathname points to a directory.
false
otherwise.public static boolean isFile(String pathname)
pathname
- the name of the filesystem object.true
if the pathname points to a directory.
false
otherwise.public static String getName(String pathname)
pathname
- the name of the file system object.public static String getParent(String pathname)
pathname
- the name of the filesystem object.public static String getBaseName(String pathname)
pathname
- the name of the file system object.public static String getExtension(String pathname)
pathname
- the name of the file system object.public static boolean setOwner(String pathname, String user, 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(String pathname)
pathname
- the name of the file system object.public static boolean exists(String pathname)
pathname
- the name of the file system object.public static String getMD5(String pathname)
pathname
- the name of the filesystem object.public static String getSHA1(String pathname)
pathname
- the name of the filesystem object.public static String getSHA256(String pathname)
pathname
- the name of the filesystem object.public static String getSHA512(String pathname)
pathname
- the name of the filesystem object.Copyright © 2008-2009 Regents University of California. All Rights Reserved.