简体   繁体   中英

delete file from jetty server using java 7

I am working on web application which is running on jetty server. In this application I am uploading and image and use this image in my jsp page. Now when I want to delete it using

Files.delete(File Path)

It gives me error

java.nio.file.FileSystemException: "File Path": The process cannot access the file because it is being used by another process.

Close all streams associated with that file before you attempt to delete it. Consider also the use of try-with-resources with the file you're uploading to.

On Windows Jetty is locking static files it serves via default servlet. It is a common issue. It has something to do with caching. See wiki: http://wiki.eclipse.org/Jetty/Howto/Deal_with_Locked_Windows_Files

You need to switch useFileMappedBuffer to false.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM