Java Resource Path Get getSystemResource(String path)

Here you can find the source of getSystemResource(String path)

Description

get System Resource

License

Open Source License

Declaration

public static File getSystemResource(String path) throws FileNotFoundException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.FileNotFoundException;
import java.net.URISyntaxException;
import java.net.URL;

public class Main {
    private static ClassLoader classLoader;

    public static File getSystemResource(String path) throws FileNotFoundException {
        try {//ww  w . j  a  va2 s.c o m
            URL url = classLoader.getResource(path);
            if (url != null) {
                return new File(url.toURI());
            } else {
                throw new FileNotFoundException(path);
            }
        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. getResources(String resourcePath, Class caller)
  2. getResourceStream(final String bundle, final String path)
  3. getResourceStream(String path)
  4. getStringFromResource(Class clazz, String path)
  5. getSystemResource(String path)
  6. loadResource(final Class bundleClazz, final Class resourceTypeclazz, final String pathToFile)
  7. loadResources(ClassLoader loader, String path)
  8. resourceExists(String path)