code: public static String replaceExtension(final String attValue, final String extName) {
          String fileName;
          int fileExtIndex;
          int index;
  
          index = attValue.indexOf(SHARP);
  
          if (attValue.startsWith(SHARP)) {
              return attValue;
          } else if (index != -1) {
              fileName = attValue.substring(0, index);
              fileExtIndex = fileName.lastIndexOf(DOT);
              return (fileExtIndex != -1)
                      ? fileName.substring(0, fileExtIndex) + extName + attValue.substring(index)
                              : attValue;
          } else {
              fileExtIndex = attValue.lastIndexOf(DOT);
              return (fileExtIndex != -1)
                      ? (attValue.substring(0, fileExtIndex) + extName)
                              : attValue;
          }
      }
docs: Replace the file extension.
  @param attValue value to be replaced
  @param extName value used to replace with
  @return replaced value