public static String changeFileNameSuffixTo ( String filename , String suffix ) { int dotPos = filename . lastIndexOf ( ' ' ) ; if ( dotPos != - 1 ) { return filename . substring ( 0 , dotPos + 1 ) + suffix ; } else { // the string has no suffix return filename ; } }
Changes the given filenames suffix from the current suffix to the provided suffix .