Java Resource File getFile(Class cls, String resource)

Here you can find the source of getFile(Class cls, String resource)

Description

get File

License

Open Source License

Declaration

public static File getFile(Class<?> cls, String resource) throws IOException 

Method Source Code


//package com.java2s;
import java.io.*;
import java.net.URL;

public class Main {
    public static File getFile(Class<?> cls, String resource) throws IOException {
        URL url = cls.getResource(resource);
        if (url == null)
            return null;
        return new File(url.getFile());
    }/*from   w ww .  j  a v  a2  s .  co m*/
}

Related

  1. getContentAsString(String resource)
  2. getDefaultWebXmlResourceLocation()
  3. getEntriesFromResourceBundle(String rbName, Map map)
  4. getFile(Class clazz, String resource)
  5. getFile(Class resourceClass, String fileName)
  6. getFile(String resource)
  7. getFile(String resourceOrFile, Class cls, boolean deleteTmpOnExit)
  8. getFileByResources(String fileName, Class clazz)
  9. getFileFromRelativeResource(final Class type, final String relativeResourceName)