I'm not the only one who makes this mistake. about file

Source: Internet
Author: User

File.create (string filePath) This usage is known to all, but the two days of use have found a problem.

You need to determine whether a file exists, create a file if it does not exist, and then write data to it, and then append the data in later time.

If the file already exists, writing the data is completely fine. When the file does not exist, the file is created immediately after the file is written to the file, error, prompting the file is being occupied by other programs.

The last reason to find out is that file created files need close: Nani? I've never been closed before. It's hard to remember what I've written.

Because you always remember that stream needs to be closed, read and write streams need close, images need to release resources, so the default feeling is that file does not need close.

When looking for reasons to see a lot of ape friends also made this mistake, in the future to remember. Remember, remind yourself.

I'm not the only one who makes this mistake. about file

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.