This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get filename from fullpath

 
indu yeturu
Ranch Hand
Posts: 123
  • 0
  • 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
  • 0
  • 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: 47258
52
  • 0
  • 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
  • 0
  • 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: 47258
52
  • 0
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


please let me know, if this code is wrong ....
 
Paul Clapham
Sheriff
Pie
Posts: 20184
25
MySQL Database
  • 0
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you ...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic