Java ClassPath Get getClasspathResource(final String resource)

Here you can find the source of getClasspathResource(final String resource)

Description

get Classpath Resource

License

Open Source License

Declaration

public static URL getClasspathResource(final String resource) 

Method Source Code

//package com.java2s;
/*/*from ww  w  .  j  av a2 s .  c  o  m*/
 *  Copyright (C) 2012 Red Hat, Inc.
 *  
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *  
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *  
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.net.URL;

public class Main {
    public static URL getClasspathResource(final String resource) {
        return Thread.currentThread().getContextClassLoader().getResource(resource);
    }
}

Related

  1. getClasspathFilePathFromName(String fileName)
  2. getClassPathFor(final Class clazz)
  3. getClasspathForClass(Class targetClass)
  4. getClassPathFromString(String classpath)
  5. getClassPathPath()
  6. getClasspathResource(String name)
  7. getClasspathResource(String path)
  8. getClasspathResourceAsFile(String resourceName)
  9. getClassPathResourcesAsStreams(String relativeResourceName)