我有一个这样的字符串(结尾处不一定总是相同的文件名,这仅是示例)

\\eabman03\edicom\Aterlasning\repstat.txt


我想得到这个

\\eabman03\edicom\Aterlasning\


因此,我想使用Java在该字符串的末尾剥离文件名。我该怎么做最有效的方法?

最佳答案

new File(stringValue).getParent()

10-01 20:44