Event.getFile (). getFileName () returns file name with full path in JSF2.0 using PrimeFaces 3.5

I am using PrimeFaces v3.5 to download files on my computer using the Firefox browser. event.getFile().getFileName() returns the file name with the full path, which causes problems. Internally PrimeFaces uses shared Apache resources. I checked javadoc , but didn't help me anymore.

To overcome this problem, I slightly modified the program as follows -

  String fileName = event.getFile().getFileName(); fileName = fileName.substring(fileName.lastIndexOf("\\")); 

But it is not reliable and reliable. Any suggestions please?

+4
windows jsf primefaces
source share
1 answer

Commons IO offers FilenameUtils#getName() for a specific purpose.

 String filename = FilenameUtils.getName(event.getFile().getFileName()); 

See also:

+9
source share

All Articles