Here you can find the source of getPathOfClass(Class cls, String filename)
public static Path getPathOfClass(Class cls, String filename)
//package com.java2s; //License from project: Apache License import java.net.URL; import java.nio.file.*; public class Main { public static Path getPathOfClass(Class cls, String filename) { URL uri = cls.getResource(filename); return uri == null ? null : Paths.get(uri.getFile()); }/*w ww.j a v a 2 s .c o m*/ }