• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get filename from fullpath

 
indu yeturu
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, how to get the filename, when I have fullpath ..
 
shan raj
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You can construct the java.lang.File object and call the method getName() to get the file name.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok thank you, i got this with "//" seperator. Thanks for considering....
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you get it to work with "//"?
 
indu yeturu
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


please let me know, if this code is wrong ....
 
Paul Clapham
Sheriff
Posts: 21113
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic