Java Path File Name nio getResourcePath(Class resourceClass, String resourceName)

Here you can find the source of getResourcePath(Class resourceClass, String resourceName)

Description

get Resource Path

License

Apache License

Parameter

Parameter Description
resourceClass - class, to which resource belongs, used to calculate package
resourceName a parameter

Exception

Parameter Description
URISyntaxException an exception

Declaration

public static Path getResourcePath(Class<?> resourceClass, String resourceName) throws URISyntaxException 

Method Source Code

//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());
    }
}

Related

  1. getPrintWriter(String className, String flushPath)
  2. getProvenanceLogFiles(final String baseName, final Collection allProvenanceLogs)
  3. getQualifiedName(String outputDir, Path path)
  4. getRelativePathFile(String fileName)
  5. getRelativePathName(Path root, Path path)
  6. getResourceRootPath(Class resourceClass, String resourceName)
  7. getRoot(final String pathName)
  8. getRootPathFromDirectory(String resourceName, URL resource)
  9. getSimpleName(String path)