Does groovy have an easy way to get a filename without the extension?

前端 未结 10 1085
-上瘾入骨i
-上瘾入骨i 2020-12-14 14:41

Say I have something like this:

new File(\"test\").eachFile() { file->  
println file.getName()  
}

This prints the full filename of eve

10条回答
  •  无人及你
    2020-12-14 15:25

    Simplest way is:

    'file.name.with.dots.tgz' - ~/\.\w+$/​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
    

    Result is:

    file.name.with.dots
    

提交回复
热议问题