I have uploaded a file in java, and I am trying something like this to get the uploaded file name
private UploadedFile uploadedFile;
System.out.println("File name: " + uploadedFile.getName());
and it is printing the filename along with its path relative to Computer as:
File name: E:\Grievances Project\Feb 2012 data\22439-29-02-2012\22439-29-02-2012.xls
how can i get only the uploaded file name irrespective of the place from where it is being uploaded like :
File name: 22439-29-02-2012.xls
System.out.println(new File(
uploadedFile.getName()).getName());
You might also look through the String methods for things like lastIndexOf("path separator") and substring(int,int), to handle it in a more generic way.
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