Four File class definitions, a
1. The file class is the only object in the Java.io package that can represent the disk file itself, providing a "file" or "directory" Operation.
2. The file class defines some platform-independent methods for the operation of files, such as building, deleting, querying, renaming, and so On.
3, you can use it to indicate the name of a file, you can also use it to represent a group of files in the directory Name.
4, in the file class contains most of the functions and the operation of the method, the object of the class can represent a specific file or folder
File class constructor
Public File (String Path)
If path is a path that actually exists, the file object represents the directory
If path is a filename, the file object represents the
Public File (String path,string Name)
Path is the pathname, name is the file name
Public file (file dir,string Name)
Dir is the pathname, name is the file name
Processing of file names
String GetName ();//get The name of a file (not including the Path)
String GetPath ();//get The path name of a file
String GetAbsolutePath ();//gets The absolute path name of a file
String getParent ();//get The top-level directory name of a file
File Properties Test
Boolean exists ();//test the existence of the file indicated by the current file object
Boolean CanWrite ();//test whether the current file is writable
Boolean CanRead ();//test whether the current file is readable
Boolean isfile ();//test whether the current file is a file (not a Directory)
Boolean isdirectory ();//test whether the current file is a directory
Common file information and tools
Long LastModified (); Get the last time the file was modified
Long length (); Gets the length of the file, in bytes
Boolean Delete (); Delete current file
Directory Operations
Boolean mkdir (); Generates a path specified by the object based on the current object
String List (); List files in the current directory
Reprint Connection: http://www.mxiaoc.com/1218.html
Java File class (reprinted Note)