/*
 * ExtUtils.java
 *
 * Created on March 16, 2004, 12:27 PM
 */
package icsDyn;

/**
 *
 * @author  Rob Snelick
 * Utility so that only certain file extension are allowed. Used inconjuction
 * with the File Chooser.
 */
public class ExtUtils {

    public final static String xml = "xml";
    public final static String html = "html";
    public final static String png = "png";
    public final static String pdf = "pdf";

    /*
     * Get the extension of a file.
     */
    public static String getExtension(java.io.File f) {
        String ext = null;
        String s = f.getName();
        int i = s.lastIndexOf('.');

        if (i > 0 &&  i < s.length() - 1) {
            ext = s.substring(i+1).toLowerCase();
        }
        return ext;
    }
    public static String getExtension(String fileName)
    {
        String ext = "";
        int i = fileName.lastIndexOf('.');
        if (i > 0 &&  i < fileName.length() - 1) {
            ext = fileName.substring(i+1).toLowerCase();
        }
        return ext;
    }
  
}
