I’m using primefaces upload file component everything works fine :
my problem that I need to retrieve the uploaded file :
public void handleFileUpload(FileUploadEvent event) {
selectedFile=(File) event.getFile();
}
the uploaded file has DefaultUploadedFile type class but I need File class type . I try to cast it but I get cast error so i found another solution it’s creating the file using the DefaultUploadedFile URI
selectedFile=new File(Uri)
but I couldn’t find a way to retrieve it from event.getFile()
Any idea will be appreciated
In your method get
InputStreamfromUploadedFile. And fromInputStreamit is easy way to haveFile. Example (How to convert InputStream to File in Java)