Java ClassLoader Load getFullPathByPkg(String pkg)

Here you can find the source of getFullPathByPkg(String pkg)

Description

get Full Path By Pkg

License

Apache License

Declaration

public static List<String> getFullPathByPkg(String pkg) 

Method Source Code


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

import java.io.File;

import java.net.URL;

import java.util.ArrayList;
import java.util.List;

public class Main {

    public static List<String> getFullPathByPkg(String pkg) {
        List<String> result = new ArrayList<>();
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        String packagePath = pkg.replace(".", "/");
        URL url = loader.getResource(packagePath);
        File dir = new File(url.getPath());
        StringBuilder str = new StringBuilder();
        for (File f : dir.listFiles()) {
            str.append(pkg).append(".");
            str.append(f.getName().replace(".class", ""));
            result.add(str.toString());/*from w  ww. j a v  a2 s  .com*/
            str.delete(0, str.length());
        }
        return result;
    }
}

Related

  1. getFileContents(String path)
  2. getFileFromPath(Object obj, String fileName)
  3. getFileFromPool(String path)
  4. getFileFullPath(String file)
  5. getFilesInPackage(String packageName)
  6. getImageFilename(String name)
  7. getInputStream(String name)
  8. getLibKoyaVersion()
  9. getLocalFile(final String aLocalPath)