| Author |
how to get filename from fullpath
|
indu yeturu
Ranch Hand
Joined: Aug 27, 2008
Posts: 123
|
|
|
Hi, how to get the filename, when I have fullpath ..
|
thanks,
indu
|
 |
shan raj
Ranch Hand
Joined: Dec 16, 2008
Posts: 42
|
|
You can construct the java.lang.File object and call the method getName() to get the file name.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 26710
|
|
|
Use the path separator, which you can find from the System#getProperties() and System#getProperty(java.lang.String) methods, and you may find more detail of in the File class. Use that as a delimiter to split the path String. This File method might also help; I am not sure.
|
 |
indu yeturu
Ranch Hand
Joined: Aug 27, 2008
Posts: 123
|
|
|
ok thank you, i got this with "//" seperator. Thanks for considering....
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 26710
|
|
|
How did you get it to work with "//"?
|
 |
indu yeturu
Ranch Hand
Joined: Aug 27, 2008
Posts: 123
|
|
please let me know, if this code is wrong ....
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 13842
|
|
Yes, it's wrong. It will only work on systems where file path entries are separated by backslashes. And the version with slashes instead, will only work on systems where file path entries are separated by slashes. So, both are unreliable. However...
shan raj wrote:You can construct the java.lang.File object and call the method getName() to get the file name.
This is the right way to do it.
|
 |
indu yeturu
Ranch Hand
Joined: Aug 27, 2008
Posts: 123
|
|
thank you ...
|
 |
 |
|
|
subject: how to get filename from fullpath
|
|
|