Java Resource Load getResources(File root, File path, Vector result)

Here you can find the source of getResources(File root, File path, Vector result)

Description

get Resources

License

Open Source License

Declaration

public static void getResources(File root, File path, Vector<String> result) throws Exception 

Method Source Code

//package com.java2s;
/*//from  ww w. j  a  v  a  2s  .  c om
 * Biocep: R-based Platform for Computational e-Science.
 *  
 * Copyright (C) 2007-2009 Karim Chine - karim.chine@m4x.org
 *  
 * Copyright (C) 2007 EMBL-EBI-Microarray Informatics
 *  
 * This program 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.
 *
 * 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.io.File;
import java.io.FileFilter;

import java.util.Vector;

public class Main {
    public static void getResources(File root, File path, Vector<String> result) throws Exception {
        if (path == null)
            path = root;
        File[] files = path.listFiles(new FileFilter() {
            public boolean accept(File pathname) {
                return pathname.isDirectory() || pathname.toString().toLowerCase().endsWith(".xml")
                        || pathname.toString().toLowerCase().endsWith(".props")
                        || pathname.toString().toLowerCase().endsWith(".properties")
                        || pathname.toString().toLowerCase().endsWith(".r")
                        || pathname.toString().toLowerCase().endsWith(".png")
                        || pathname.toString().toLowerCase().endsWith(".jpg")
                        || pathname.toString().toLowerCase().endsWith(".gif")
                        || pathname.toString().toLowerCase().endsWith(".html")
                        || pathname.toString().toLowerCase().endsWith(".sql");
            }
        });
        if (files == null)
            return;
        for (int i = 0; i < files.length; i++) {
            if (files[i].isDirectory()) {
                getResources(root, files[i], result);
            } else {
                String absolutepath = files[i].getAbsolutePath();
                String name = absolutepath.substring(root.getAbsolutePath().length()).replace('\\', '/');
                result.add(name);
            }
        }
    }
}

Related

  1. getResourceNames(String resName)
  2. getResourceNamesFromDir(File dir, String extension)
  3. getResourcePath()
  4. getResourcePath(Class c, String name)
  5. getResourceReader(final String aResName)
  6. getResources(final Pattern pattern)
  7. getResourceScripts(String path)
  8. getResourcesFromDirectory(File directory)
  9. getResourcesFromDirectory(final File directory, final Pattern pattern)