Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   'basename' function (without re-inventing the wheel) (http://www.velocityreviews.com/forums/t124672-basename-function-without-re-inventing-the-wheel.html)

Ronald Fischer 07-22-2003 11:38 AM

'basename' function (without re-inventing the wheel)
 
Does someone know if there is in the JDK something like the 'basename' function
from Unix or C, i.e. a function which takes a path such as

foo/bar/baz

and returns the filename, i.e.

baz.

Of course it is easy to implement this, but I don't want to re-invent the wheel,
if such a function is already available.

Ronald

Jacob 07-22-2003 12:05 PM

Re: 'basename' function (without re-inventing the wheel)
 
Ronald Fischer wrote:
> Does someone know if there is in the JDK something like the 'basename' function
> from Unix or C, i.e. a function which takes a path such as
>
> foo/bar/baz
>
> and returns the filename, i.e.
>
> baz.
>
> Of course it is easy to implement this, but I don't want to re-invent the wheel,
> if such a function is already available.
>
> Ronald


The function is available in java.io.File:

String name = (new File("foo/bar/baz")).getName();




All times are GMT. The time now is 10:10 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.