Java Resource Load getResource(String fileName)

Here you can find the source of getResource(String fileName)

Description

get Resource

License

BSD License

Declaration

public static File getResource(String fileName) 

Method Source Code


//package com.java2s;
//License from project: BSD License 

import java.io.File;

public class Main {
    private static String bsearchAppFolderStr = System.getProperty("bsearch.appfolder");

    public static File getResource(String fileName) {
        return new File(attemptResolvePathFromBSearchRoot("resources/" + fileName));
    }/* www .  j a  v a2  s  .c  o m*/

    public static String attemptResolvePathFromBSearchRoot(String pathStr) {
        // check if the program was started in the NetLogo folder, in which case behaviorsearch is in a subfolder.
        // NOTE: As of NetLogo 4.1 anyway,
        // if you don't start the JVM with the NetLogo app folder as the current working directory,
        // then NetLogo doesn't find its built-in extensions folder, and some other things...       
        File rootDir;
        if (bsearchAppFolderStr != null && !bsearchAppFolderStr.equals("")) {
            rootDir = new File(bsearchAppFolderStr);
        } else {
            rootDir = new File("behaviorsearch");
        }
        if (rootDir.exists() && rootDir.isDirectory()) {
            return new File(rootDir, pathStr).getAbsolutePath();
        }
        return pathStr;
    }
}

Related

  1. getResource(Class clazz, String name, String charset)
  2. getResource(Class c, String name)
  3. getResource(ClassLoader classLoader, final String path)
  4. getResource(final String aResName)
  5. getResource(final String resource)
  6. getResource(String fileName, int type)
  7. getResource(String name)
  8. getResource(String path)
  9. getResource(String propertiesPath)