Java Path File Extention nio changeFileExtension(Path fileName, String extension)

Here you can find the source of changeFileExtension(Path fileName, String extension)

Description

change File Extension

License

Open Source License

Declaration

public static Path changeFileExtension(Path fileName, String extension) 

Method Source Code

//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*/
}

Related

  1. asPaths(final Iterable files)
  2. changeExtension(Path source, String extension)
  3. fileExtension(final Path thePath)
  4. fileRenamer(final String fromPath, final String toPath, @Nullable final String toExtension, final boolean junkPaths)
  5. findFilesWithExtension(Path directory, String targetExtension)
  6. getAllPaths(Path root, final String... extensions)