Java File Naked Name Get getFileWithoutExtension(File file)

Here you can find the source of getFileWithoutExtension(File file)

Description

get File Without Extension

License

Open Source License

Declaration

public static File getFileWithoutExtension(File file) 

Method Source Code

//package com.java2s;

import java.io.File;

public class Main {
    public static File getFileWithoutExtension(File file) {
        return getFileWithOtherExtension(file, "");
    }// w  ww  .  j ava 2s.  c o  m

    public static File getFileWithOtherExtension(File file, String newExtension) {
        String name = file.getName();
        int lastDot = name.lastIndexOf('.');
        if (lastDot < 0) {
            lastDot = name.length();
        }
        return new File(file.getParent(), name.substring(0, lastDot) + newExtension);
    }
}

Related

  1. getFileNameNoExt(File file)
  2. getFileNameNoExt(String path)
  3. getFileNameNoExtension(File file)
  4. getFileWithoutEnding(String absolutePath)
  5. getFileWithoutExtension(File f)