explain the close() method in Java in Layman's terms

前端 未结 3 678
南笙
南笙 2020-12-18 06:41

I went through a java tutorial that allowed me to create a text file and write the words,\"20 Bruce Wayne\" in it. The last method that is called in the main class is named

3条回答
  •  天涯浪人
    2020-12-18 07:04

    When a file is "opened," the OS marks the file as locked, generally so it can't be deleted by other processes while it's being used. x.close() undoes the lock, allowing the OS and other processes to do what it wishes with the file.

提交回复
热议问题