posted 11 years ago
Assuming that you mean you want to replace everything in front of the last full stop then two of the very many approaches are :-
1) Find the index of the last full stop and use substring() to extract the extension. Easy enough to then just create the new file name. (3 lines of code)
2) Use String.replaceFirst() with a regex that select everything up to the last full stop and replace it with your new file name. (1 line of code)