I have a array variable filesFound
that holds a filename. How do I go about removing the last number part including its extension.
...
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
...
Arrays.copyOf
returns a new array, so you have to assign it to t or a new variable:
t = Arrays.copyOf(t, t.length - 1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With