Java.io.File class

Source: Internet
Author: User

Java.io.File class
1. All classes and interfaces related to input and output are defined under the Java.io package
2.File is a class. Can have a constructor to create its object. This object corresponds to a file (. txt. avi. doc. ppt. mp3. jpg) or a file folder
The 3.File class object is platform-independent.
The method in 4.File only involves how to create, delete, rename, and so on. Only the contents of the file are involved. File is powerless. Must be completed by IO stream.
Objects of the 5.File class are often used as constructors for the detailed class of IO streams.

① Interview file name
GetName (): Returns the name of the file
GetPath (): Returns the path to the file
Getabsolutefile (): Returns the absolute file name
GetAbsolutePath (): Returns the absolute path
GetParent (): Return to Parent Path
Renameto (file NewName): Renaming of Files File1.renameto (file2): file1 must exist, file2 must not exist

② file Detection
Exists (): Infer whether a file or folder exists
CanWrite (): Returns whether the file or folder is writable
CanRead (): Returns whether the file or folder is readable
Isfile (): Infers whether the file object is a document
Isdirectory (): Infer whether the file object is a folder

③ Getting general file information
LastModified (): Returns the last modification time of a file or folder
Length (): Returns the size of the file or folder

④ file Operation related
CreateNewFile (): Create a file
Delete (): Deletes a file or folder

⑤ folder Operation related
MkDir (): Creates a file folder. Ability to return true only if the upper-level file folder exists
Mkdirs (): Creates a file folder. If the upper-level file folder does not exist, create
List (): Returns the entire contents of the directory as an array of strings
Listfiles (): Returns the contents of the directory in the form of an array of files

Java.io.File class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.