code: @Pure
  	public static File replaceExtension(File filename, String extension) {
  		if (filename == null) {
  			return null;
  		}
  		if (extension == null) {
  			return filename;
  		}
  		final File dir = filename.getParentFile();
  		final String name = filename.getName();
  		final int idx = name.lastIndexOf(getFileExtensionCharacter());
  		final StringBuilder n = new StringBuilder();
  		if (idx < 0) {
  			n.append(name);
  		} else {
  			n.append(name.substring(0, idx));
  		}
  		if (!name.endsWith(EXTENSION_SEPARATOR) && !extension.startsWith(EXTENSION_SEPARATOR)) {
  			n.append(EXTENSION_SEPARATOR);
  		}
  		n.append(extension);
  		return new File(dir, n.toString());
  	}
docs: Replace the extension of the specified filename by the given extension.
  If the filename has no extension, the specified one will be added.
  
  @param filename is the filename to parse.
  @param extension is the extension to remove if it is existing.
  @return the filename without the extension.