Java Learning at a glance--file class file processing

Source: Internet
Author: User

Java Learning at a glance--file class file processing

File Class (Java.io.File)

constructor function:

File (String Path)

File (String parent,string Child)

File (file parent,string child)

To create a file:

Boolean createnewfile ();

To create a folder:

Boolean mkdir (); Used to create a layer of undefined folders Boolean mkdirs ();

Used to create multi-level undefined folders, equivalent to multiple mkdir ()

Delete files/folders:

Boolean delete ();

Note: If a folder is not empty, you cannot use. Delete () to delete the folder

Rename:

Boolean rename (File FILE0); [File.rename (file FILE0);]

Note: If the same path is renamed, the different paths are renamed plus cut

Judging function:

Boolean canRead (); Whether it is readable

Boolean canWrite (); Whether it can be written

Boolean Ishidden (); Whether to hide

Boolean isdirectory; Whether it is a folder

Boolean isfile (); Whether it is a file

Boolean exists (); Whether there is

Get Features:

String GetAbsolutePath (); Absolute path

String GetPath (); Relative path

String GetName (); Get file name

Long length (); Get length size

Long LastModified (); Gets the millisecond value of the last modified time

Get a list of files:

String[] List (); Gets an array of all file or folder names (strings) in the specified directory

File[] ListFile (); Gets an array of all files or folders in the specified directory

Java Learning at a glance--file class file processing

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.