to return the name of the file. This works fine on windows platform, but on unix it returns the absolute path. Is there any other way to get the file name which works both on windows and unix ?
Jigar Naik
Hari haran Ravi
Greenhorn
Joined: Aug 11, 2010
Posts: 26
posted
0
Hi Jigar, If it returns an absolute path, process it using String Manipulations and then get the file name out of it..
I will give you an idea. In an absolute path the filename will start after the last slash in the absolute path. So find the index of the last slash using the lastIndexOf function and then use substring function to return the file name.
actually the application is deployed on unix so File.separator is returning / but i am uploading file from client(browser running on windows) which is giving \ as separator.
Note that different browsers return different things for uploaded files--some return a path, some return just the file name. Make sure you code accordingly.
Jigar Naik
Ranch Hand
Joined: Dec 12, 2006
Posts: 744
posted
0
yes david, i noticed that. Thanks
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: get file name using java on unix platform