You can do it. These works
ClassLoader loader = this.getClass().getClassLoader(); URL url = loader.getResource("resource name"); String[] filePath = null; String protocol = url.getProtocol(); if(protocol.equals("jar")){ url = new URL(url.getPath()); protocol = url.getProtocol(); } if(protocol.equals("file")){ String[] pathArray = url.getPath().split("!"); filePath = pathArray[0].split("/",2); }
Required file = new file (FilePath [1]);
source share