Java File Programming Summary

Source: Internet
Author: User

One of the file programming is the file operation, is new, delete, copy, rename

New file with CreateNewFile () method, to handle IOException exception

New folder with Mkdirs () method

Delete a file and an empty folder directly with the Delete () method

The classes for copying and pasting files and folders have been given

A class that deletes a content folder has been given

Name of the file:

1. Determine if file exists

2. Create a renamed Filetwo

3.fileTwo Call exists () method confirms no duplicate name

4.file.renameto (Filetwo);

Note that file and Filetwo folders are guaranteed to be the same

Rename a folder, even if there is a file inside the folder can be renamed successfully, but delete the folder is not

-----------

The given class is written directly using the output stream FileOutputStream to write to the file and directly using the input stream FileInputStream to read the file

Of course, there are many subclasses of abstract reader and writer class, as well as their methods and methods of use.

The world of Java is profound, the moment also can not stop, time expensive like oil

Java File Programming Summary

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.