Java File Extension Name Extract ExtractFileExtension(String file_name)

Here you can find the source of ExtractFileExtension(String file_name)

Description

Extracts the file extension

License

Open Source License

Parameter

Parameter Description
file_name a parameter

Declaration

public static String ExtractFileExtension(String file_name) 

Method Source Code

//package com.java2s;
/*Copyright 2008 by Vladimir Polony, Stupy 24, Banska Bystrica, Slovakia
    /* w  w  w.jav a 2  s .c o  m*/
This file is part of OpenRep FREE homeopathic software.
    
OpenRep FREE is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
    
OpenRep FREE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with OpenRep FREE.  If not, see <http://www.gnu.org/licenses/>.*/

public class Main {
    /** standard extension of any file == '.' */
    public static final String FILE_EXTENSION_SEPARATOR = ".";

    /** Extracts the file extension
     * 
     * @param file_name
     * @return
     */
    public static String ExtractFileExtension(String file_name) {
        int pos = file_name.lastIndexOf(FILE_EXTENSION_SEPARATOR);
        if (pos != -1)
            return file_name.substring(pos + 1);
        else
            return "";
    }
}

Related

  1. extractFileExt(String _sFilePathName)
  2. extractFileExt(String filePath)
  3. extractFileExtension(String filename)
  4. extractFileExtension(String filename)
  5. extractFileExtension(String fileName)
  6. extractFileExtension(String filename)