Infolinks In Text Ads

Jun 29, 2010

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;
    }

3 comments:

  1. Sir , Bahut acha post hai well sir aap AJAX ke bare post kyo nahi karta.

    Prashant Kumar

    ReplyDelete
  2. Sir, Ek aur baat puchni hai AJAX ka use kar ke "select Country dropdown automatically State name in dropdown & City Name in dropdown.

    Prashant Kumar

    ReplyDelete
  3. But it is also good to check if '.' is last symbol in filename

    ReplyDelete

LinkWithin

Related Posts Plugin for WordPress, Blogger...