Java File Name Get getFileName(File file)

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

Description

get File Name

License

Apache License

Declaration

public static String getFileName(File file) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

public class Main {
    public static String getFileName(File file) {
        String[] nameArr = file.getName().split("\\.");
        StringBuilder name = new StringBuilder();

        for (int i = 0; i < nameArr.length - 1; i++) {
            name.append(nameArr[i]);/*from w  w w  . j av a 2  s. com*/

            if (i != nameArr.length - 2) {
                name.append(".");
            }
        }
        return name.toString();
    }
}

Related

  1. getFileName(Class cls, String ext)
  2. getFileName(File element)
  3. getFileName(File f)
  4. getFileName(File f)
  5. getFileName(File f)
  6. getFileName(File file)
  7. getFileName(File file)
  8. getFileName(File file)
  9. getFilename(File file)