Here you can find the source of getAppPath(Class clazz)
Parameter | Description |
---|---|
URISyntaxException | an exception |
public static File getAppPath(Class clazz) throws URISyntaxException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.net.URISyntaxException; public class Main { /**/*from w ww.java2 s . com*/ * @return * @throws URISyntaxException */ public static File getAppPath(Class clazz) throws URISyntaxException { File appPath = new File(clazz.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()); return appPath.isFile() ? appPath.getParentFile() : appPath; } }