How to get file extension in java code example

Get file extension in java code example

public static String getFileExtension(String filePath)
    {
        File f = new File(filePath);
        String name = f.getName();
        int k = name.lastIndexOf(".");
        String ext = null;
        if(k != -1)
            ext = name.substring(k + 1, name.length());
        return ext;
    }

Popular posts from this blog

What is NBioBSP Java Library?

Draw arrow line example

Capture image from webcam java code, examples