Java File Extension Name Get getFileExtension(File file)

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

Description

get File Extension

License

Apache License

Declaration

public static String getFileExtension(File file) 

Method Source Code

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

import java.io.File;

public class Main {
    public static String getFileExtension(File file) {

        String filename = file.getName();
        int extensionIndex = filename.lastIndexOf(".");
        String extension;/*  w w w.j a va 2s .  c  om*/
        if (extensionIndex == -1) {
            extension = "";
        } else {
            extension = filename.substring(extensionIndex + 1, filename.length());
        }

        return extension;
    }
}

Related

  1. getFileExtension(File f)
  2. getFileExtension(File f)
  3. getFileExtension(File f)
  4. getFileExtension(File file)
  5. getFileExtension(File file)
  6. getFileExtension(File file)
  7. getFileExtension(File file)
  8. getFileExtension(File file)
  9. getFileExtension(File file)