Here you can find the source of getResourcePath(Class> resourceClass, String resourceName)
Parameter | Description |
---|---|
resourceClass | - class, to which resource belongs, used to calculate package |
resourceName | a parameter |
Parameter | Description |
---|---|
URISyntaxException | an exception |
public static Path getResourcePath(Class<?> resourceClass, String resourceName) throws URISyntaxException
//package com.java2s; //License from project: Apache License import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Path; import java.nio.file.Paths; public class Main { /**/*from w w w . jav a 2 s .co m*/ * * @param resourceClass * - class, to which resource belongs, used to calculate package * @param resourceName * @return * @throws URISyntaxException */ public static Path getResourcePath(Class<?> resourceClass, String resourceName) throws URISyntaxException { URL url = resourceClass.getResource(resourceName); return Paths.get(url.toURI()); } }