Sparrow flights
Notes and thoughts about my life and work as a Computer Scientist and Engineer.
2012-10-04
Groovy one-liner to extract file name without extension
Does groovy have an easy way to get a filename without the extension? - Stack Overflow
:
file.name.lastIndexOf('.').with {it != -1 ? file.name[0..<it] : file.name}
or with a simple regexp:
file.name.replaceFirst(~/\.[^\.] $/, ''
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment