private String changeExtension(String fileName,String extension){
  if (fileName == null) {
    return null;
  }
  int lastIndexOf=fileName.lastIndexOf(".");
  return lastIndexOf != -1 ? fileName.substring(0,lastIndexOf + 1) + extension : fileName + "." + extension;
}

private String changeExtension ( String fileName , String extension ) { if ( fileName == null ) { return null ; } int lastIndexOf = fileName . lastIndexOf ( "." ) ; return lastIndexOf != - 1 ? fileName . substring ( 0 , lastIndexOf + 1 ) + extension : fileName + "." + extension ; }
replaces extension if there is any
