Here you can find the source of getClassloaderRootDir(Class> forClass)
Parameter | Description |
---|---|
forClass | The class used to get the responsible ClassLoader . |
public static File getClassloaderRootDir(Class<?> forClass)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.net.URL; public class Main { /**/*w w w . j av a2s . c o m*/ * Provides a binaries root directory. E.g. a 'target/classes' directory. * <p> * Does only work well if the classes located in a directory structure. * * @param forClass The class used to get the responsible {@link ClassLoader}. * @return the binaries root directory. */ public static File getClassloaderRootDir(Class<?> forClass) { URL rootUrl = forClass.getClassLoader().getResource("."); return new File(rootUrl.getFile()); } }