Home > Java > javaTutorial > body text

What to do if the java file cannot be deleted

藏色散人
Release: 2020-04-07 10:06:28
Original
4396 people have browsed it

What to do if the java file cannot be deleted

What should I do if the java file cannot be deleted?

Solution to using Java file to delete file.delete() that cannot delete a file

Today, when using springboot to delete a file, it cannot be deleted normally. After a period of investigation, we found that the problem was caused by not closing the data stream after reading the file, so we recorded it again.

Recommended tutorial: "java learning"

Find the reason

The file cannot be deleted. Generally, the file is occupied by a certain program process. In the code It is very likely that the stream operation was not closed after the data flow operation was completed. If it is a DB file, it is also possible that the DB operation was not closed. Search carefully.

Solution

Find the stream or DB file operation that is not closed, add a closing statement, and then execute the file.delete() operation.

The above is the detailed content of What to do if the java file cannot be deleted. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template