PrimeFaces UploadedFile only exposes the InputStream, not the File itself. How can I delete it after processing the stream?
PrimeFaces UploadedFile only exposes the InputStream, not the File itself. How can I delete
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
FilenorInputStreamreferences to it when the Java Garbage Collector runs.So if you can make absolutely sure that you close the
InputStreamafter processing (in thefinallyblock!), then you don’t need to worry about cleanup.