⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fileutils.java

📁 非常好用的代码源代码统计分析工具的源代码
💻 JAVA
字号:
/* * FileUtils.java - a class for usefull functions on files. * Copyright (C) 2003-2004 Rob Spoor * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This program 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */package nl.icemanx.io;import java.io.*;import java.util.*;/** * FileUtils contains several usefull functions on strings. * * @author  Rob Spoor * @version 0.3, 2003-12-29 */public class FileUtils{    /**     * Private constructor to prevent creation of instances.     */    private FileUtils()    {    }    /**     * Returns a list with the full filenames of all files in the directory.     *     * @param start The directory to start in.     * @param filter The filefilter to use.     * @param recurse Whether or not to recurse.     * @return A list with all full filenames.     * @throws IOException If <tt>start</tt> is not a directory.     */    public static List getFiles(File start, FileFilter filter,                                boolean recurse) throws IOException    {        if (!start.isDirectory())        {            throw new IOException("No directory: " + start.getAbsolutePath());        }        List files = new ArrayList();        File[] list = start.listFiles(filter);        for (int i = 0; i < list.length; i++)        {            if (list[i].isFile())            {                files.add(list[i].getAbsolutePath());            }            else if (recurse && list[i].isDirectory())            {                files.addAll(getFiles(list[i], filter, recurse));            }        }        return files;    }    /**     * @param file The file to get the extension of.     * @return The extension of the given file.     * @since 0.3     */    public static String getExtension(File file)    {        String name = file.getName();        int index = name.lastIndexOf(".");        if (index != -1)        {            return name.substring(index+1);        }        return "";    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -