PrimeFaces UploadedFile only exposes the InputStream, not the File itself. How can I delete it after processing the stream?
PrimeFaces uses Apache Commons FileUpload under the covers for this. It will create the file as a temporary file and hence the file will already be automatically deleted if there are no open File
nor InputStream
references to it when the Java Garbage Collector runs.
So if you can make absolutely sure that you close the InputStream
after processing (in the finally
block!), then you don't need to worry about cleanup.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With