Example usage for java.net URL getPath

List of usage examples for java.net URL getPath

Introduction

In this page you can find the example usage for java.net URL getPath.

Prototype

public String getPath() 

Source Link

Document

Gets the path part of this URL .

Usage

From source file:com.ebay.logstorm.core.compiler.PipelineCompiler.java

public static Pipeline compileResource(String resource) throws IOException, PipelineException {
    URL resourceUrl = PipelineCompiler.class.getResource(resource);
    if (resourceUrl == null) {
        throw new IOException("Resource " + resource + " not found");
    } else {//from   w  w  w .ja  va2 s. c  o  m
        return compileConfigString(FileUtils.readFileToString(new File(resourceUrl.getPath())));
    }
}

From source file:at.beris.virtualfile.util.UrlUtils.java

public static URL newUrlReplacePath(URL context, String path) throws IOException {
    String contextUrlString = context.toString();
    String newUrlString = contextUrlString.substring(0, contextUrlString.length() - context.getPath().length());
    newUrlString += path;//w w w.  j  ava2 s.com
    return new URL(newUrlString);
}

From source file:com.norconex.commons.lang.ClassFinder.java

/**
 * Finds the names of all subtypes of the super class,
 * scanning the roots of this class classpath.
 * This method is null-safe.  If no classes are found, 
 * an empty list will be returned.//from   ww w . j a v  a  2  s .c o  m
 * @param superClass the class from which to find subtypes
 * @return list of class names
 * @since 1.4.0
 */
public static List<String> findSubTypes(Class<?> superClass) {
    List<String> classes = new ArrayList<String>();
    if (superClass == null) {
        return classes;
    }
    Enumeration<URL> roots;
    try {
        roots = ClassFinder.class.getClassLoader().getResources("");
    } catch (IOException e) {
        LOG.error("Cannot obtain class roots for class: " + superClass, e);
        return classes;
    }
    while (roots.hasMoreElements()) {
        URL url = roots.nextElement();
        File root = new File(url.getPath());
        classes.addAll(findSubTypes(root, superClass));
    }
    return classes;
}

From source file:de.fhg.iais.asc.xslt.binaries.download.Downloader.java

private static URI createURI(URL url) throws URISyntaxException {
    return new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(),
            url.getQuery(), url.getRef());
}

From source file:com.o2d.pkayjava.editor.Main.java

public static String getLocalArtPath(String directoryName) {
    // TODO: wtf with all the multiplatform shit? anyone had experience?
    URL inputUrl = Main.class.getClassLoader().getResource("art/" + directoryName);
    String input;//from w w  w. j a va  2  s  .  c  o  m
    if (inputUrl != null) {
        input = inputUrl.getPath();
    } else {
        inputUrl = Main.class.getClassLoader().getResource(directoryName);
        if (inputUrl != null) {
            input = inputUrl.getPath();
        } else {
            input = "../art/" + directoryName;
        }
    }
    File file = new File(input);
    if (!file.exists()) {
        input = "art/" + directoryName;
    }

    return input;
}

From source file:com.predic8.membrane.core.util.HttpUtil.java

public static String getPathAndQueryString(String dest) throws MalformedURLException {
    URL url = new URL(dest);

    String uri = url.getPath();
    if (url.getQuery() != null) {
        return uri + "?" + url.getQuery();
    }//from   w w  w  . j a  v  a  2s. c o m
    return uri;
}

From source file:com.thruzero.common.core.utils.FileUtilsExt.java

public static File urlToFile(final URL url) {
    return new File(url.getPath());
}

From source file:com.uwsoft.editor.Main.java

public static String getLocalArtPath(String directoryName) {
    // TODO: wtf with all the multiplatform shit? anyone had experience?
    URL inputUrl = Main.class.getClassLoader().getResource("art/" + directoryName);
    String input;/*w ww .j  av a2  s .  c o m*/
    if (inputUrl != null) {
        input = inputUrl.getPath();
    } else {
        inputUrl = Main.class.getClassLoader().getResource(directoryName);
        if (inputUrl != null) {
            input = inputUrl.getPath();
        } else {
            input = "overlap2d/art/" + directoryName;
        }
    }
    File file = new File(input);
    if (!file.exists()) {
        input = "art/" + directoryName;
    }

    return input;
}

From source file:com.networknt.light.server.handler.loader.Loader.java

public static File getFileFromResourceFolder(String folder) {
    URL url = Thread.currentThread().getContextClassLoader().getResource(folder);
    File file = null;//from  ww  w . j a v  a  2  s .  c om
    try {
        file = new File(url.toURI());
    } catch (URISyntaxException e) {
        file = new File(url.getPath());
    } finally {
        return file;
    }
}

From source file:com.opengamma.web.WebResourceTestUtils.java

public static JSONObject loadJson(String filePath) throws IOException, JSONException {
    URL jsonResource = ClassLoader.getSystemResource(filePath);
    assertNotNull(jsonResource);//  w  w  w  .ja v a 2  s . c  o m
    String jsonText = FileUtils.readFileToString(new File(jsonResource.getPath()));
    return new JSONObject(jsonText);
}