    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *      http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017package org.apache.commons.io.filefilter;
    018
    019import java.io.File;
    020import java.io.Serializable;
    021
    022/**
    023 * This filter accepts <code>File</code>s that are files (not directories).
    024 * <p>
    025 * For example, here is how to print out a list of the real files
    026 * within the current directory:
    027 *
    028 * <pre>
    029 * File dir = new File(".");
    030 * String[] files = dir.list( FileFileFilter.FILE );
    031 * for ( int i = 0; i &lt; files.length; i++ ) {
    032 *     System.out.println(files[i]);
    033 * }
    034 * </pre>
    035 *
    036 * @since 1.3
    037 *
    038 * @see FileFilterUtils#fileFileFilter()
    039 */
    040public class FileFileFilter extends AbstractFileFilter implements Serializable {
    041
    042    private static final long serialVersionUID = 5345244090827540862L;
    043    /** Singleton instance of file filter */
    044    public static final IOFileFilter FILE = new FileFileFilter();
    045
    046    /**
    047     * Restrictive constructor.
    048     */
    049    protected FileFileFilter() {
    050    }
    051
    052    /**
    053     * Checks to see if the file is a file.
    054     *
    055     * @param file  the File to check
    056     * @return true if the file is a file
    057     */
    058    @Override
    059    public boolean accept(final File file) {
    060        return file.isFile();
    061    }
    062
    063}