Here you can find the source of changeFileExtension(Path fileName, String extension)
public static Path changeFileExtension(Path fileName, String extension)
//package com.java2s; //License from project: Open Source License import java.nio.file.Path; import java.nio.file.Paths; public class Main { public static Path changeFileExtension(Path fileName, String extension) { String name = fileName.getFileName().toString(); int length = name.length(); String nameWithoutExt = name.substring(0, length - 3); return Paths.get(nameWithoutExt.concat(extension)); }/* ww w .j a v a 2s. com*/ }