Java Path File Name nio getPath(Class baseClass, String resourceName)

Here you can find the source of getPath(Class baseClass, String resourceName)

Description

get Path

License

Apache License

Declaration

static public Path getPath(Class<?> baseClass, String resourceName)
        throws FileNotFoundException, URISyntaxException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.*;
import java.net.URISyntaxException;
import java.net.URL;

import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {

    static public Path getPath(Class<?> baseClass, String resourceName)
            throws FileNotFoundException, URISyntaxException {
        URL url = baseClass.getResource(resourceName);
        if (url == null) {
            throw new FileNotFoundException(String.format(
                    "Resource file is not found. %s", resourceName));
        }//  w  w  w.  jav  a  2 s . co m
        return Paths.get(url.toURI());
    }
}

Related

  1. getNamePart(Path file)
  2. getNameWithoutSuffix(Path path)
  3. getNormalizedFileName(Path file)
  4. getPackageURI(String pkgName, String pkgPath, String currentPkgName)
  5. getPath(Class example, String filename)
  6. getPath(File dir, String filename)
  7. getPath(final String fullFileName)
  8. getPath(Object name)
  9. getPath(String dirName, String fileName)