我有一個包含文件名的數組變量filesFound
。我如何去除最後的數字部分,包括其擴展名。如何拆分字符串,刪除最後一個元素並返回到Java?
...
File[] filesFound = SomeUtils.findFile("xyz","c:\\")
//fileFound[0] is now "abc_xyz_pqr_27062016.csv"
//What I need is "abc_xyz_pqr" only
String[] t = filesFound[0].toString().split("_")
Arrays.copyOf(t, t.length - 1) //this is not working
...
拿什麼不工作? – Jens