Java Resource Get getResourceAsFile(Class clazz, String rscName)

Here you can find the source of getResourceAsFile(Class clazz, String rscName)

Description

get Resource As File

License

Apache License

Declaration

public static File getResourceAsFile(Class<?> clazz, String rscName) 

Method Source Code

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

import java.io.File;

import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;

public class Main {
    public static File getResourceAsFile(Class<?> clazz, String rscName) {
        File file = null;/*ww w.  j  a  v a2 s.co m*/
        try {
            final URL url = clazz.getClassLoader().getResource(rscName);
            if (url != null)
                file = new File(new URI(url.toString()));
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
        return file;
    }
}

Related

  1. getResourceAsFile(Class clazz, String resource)
  2. getResourceAsFile(Class klass, String resource)
  3. getResourceAsFile(Class sourceClass, String reference)
  4. getResourceAsFile(Class clazz, String fn)
  5. getResourceAsFile(Class clazz, String name)
  6. getResourceAsFile(final Class clazz, final String name)
  7. getResourceAsFile(final String filename, final Class theClass)
  8. getResourceAsFile(String name)
  9. getResourceAsStream(Class aClass, String name)