Java ClassLoader Load getFile(Object obj, String filename)

Here you can find the source of getFile(Object obj, String filename)

Description

get File

License

Apache License

Declaration

public static File getFile(Object obj, String filename) 

Method Source Code


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

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

public class Main {
    public static File getFile(Object obj, String filename) {
        String file = obj.getClass().getPackage().getName().replace('.', '/') + '/' + filename;
        URL url = obj.getClass().getClassLoader().getResource(file);
        return new File(url.getFile());
    }/* www  .  j  a v  a2s  .  c o  m*/
}

Related

  1. getConfigFileInputStream(String configFilePath)
  2. getContentFromFile(String fileName, Object context)
  3. getDirectories(String path)
  4. getFile(final String filename)
  5. getFile(final String name)
  6. getFileContents(String filename)
  7. getFileContents(String path)
  8. getFileFromPath(Object obj, String fileName)
  9. getFileFromPool(String path)