cn.guoyukun.spring.utils.ImagesUtils.java Source code

Java tutorial

Introduction

Here is the source code for cn.guoyukun.spring.utils.ImagesUtils.java

Source

/**
 * Copyright (c) 2005-2012 https://github.com/zhangkaitao
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package cn.guoyukun.spring.utils;

import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.ArrayUtils;

/**
 * <p>User: 
 * <p>Date: 13-2-12 ?9:29
 * <p>Version: 1.0
 */
public class ImagesUtils {

    private static final String[] IMAGES_SUFFIXES = { "bmp", "jpg", "jpeg", "gif", "png", "tiff" };

    /**
     * ?
     *
     * @param filename
     * @return
     */
    public static boolean isImage(String filename) {
        if (filename == null || filename.trim().length() == 0)
            return false;
        return ArrayUtils.contains(IMAGES_SUFFIXES, FilenameUtils.getExtension(filename).toLowerCase());
    }

}