APISonar


java.net.URL.getPath

> java > net > URL > getPath
java APIs net APIs URL APIs getPath APIs

Example 1
private static String getNameFromURL(URL fURL) {
    //TODO add handling for http
    if ("jar".equals(fURL.getProtocol())) {
      int n = fURL.getPath().lastIndexOf(".jar!/");
      int k = fURL.getPath().substring(0, n).lastIndexOf("/");
      if (n > -1) {
        return "JAR:" + fURL.getPath().substring(k + 1, n) + fURL.getPath().substring(n + 5);
      }
    }
    return "???:" + fURL.getPath();
  }
Example 2
protected int hashCode( URL u )
  {
    return (u.getProtocol() + u.getHost() + u.getPath()).hashCode();
  }
Example 3
private URL _url;

  public ResourcePath getPath()
  {
    return ResourcePath.parse( _url.getPath() );
  }
Example 4
private boolean containsResource(Set<URL> resources, URL resourceToFind) {
        for (URL resource : resources) {
            if (resourceToFind.getPath().equals(resource.getPath())) {
                return true;
            }
        }
        return false;
    }
Example 5
public FileObject fromServer(URL serverURL) {
        String path;
        try {
            path = serverURL.toURI().getPath();
        } catch (URISyntaxException ex) {
            path = serverURL.getPath(); // fallback
        }
        return fromServer(path);
    }
Example 6
public boolean isOnClasspath(URL path) {
    if (classPath.isEmpty()) {
      storeClassPath();
    }
    for (URL entry : classPath) {
      if (new File(path.getPath()).equals(new File(entry.getPath()))) {
        return true;
      }
    }
    return false;
  }
Example 7
public static String getJarPath(Class<?> clazz)
            throws FileNotFoundException {
        URL resource = clazz.getClassLoader().getResource(
                clazz.getCanonicalName().replace(".", "/") + ".class");
        if (resource.getProtocol().equals("jar")) {
            return resource.getPath().substring(
                    resource.getPath().indexOf(':') + 1,
                    resource.getPath().indexOf('!'));
        }
        throw new FileNotFoundException("Jar for " + clazz.getName()
                + " class is not found");
    }
Example 8
private String getPath() {
        URL resource = getClass().getClassLoader().getResource("C101_solomon.txt");
        if (resource == null) throw new IllegalStateException("file C101_solomon.txt does not exist");
        return resource.getPath();
    }
Example 9
protected void setUp () {
        URL clazURL = getClass ().getResource ("testapps/JspLineBreakpointApp.class");
        assertNotNull (clazURL);
        testAppCLAZ = clazURL.getPath();
        URL smapURL = getClass ().getResource ("testapps/JspLineBreakpointApp.txt");
        assertNotNull (smapURL);
        testAppSMAP = smapURL.getPath();
    }
Example 10
private String locateRuntime() {
		final ClassLoader loader = Thread.currentThread().getContextClassLoader();
		final URL runtimeSrc = loader.getResource("JavaScript/src");
		if ( runtimeSrc==null ) {
			throw new RuntimeException("Cannot find JavaScript runtime");
		}
		if(isWindows()){
			return runtimeSrc.getPath().replaceFirst("/", "");
		}
		return runtimeSrc.getPath();
	}
Example 11
public final URL url;

    private String getProjectName() {
        String p = url.getPath();
        if(p.endsWith("/")) p = p.substring(0,p.length()-1);

        int idx = p.lastIndexOf('/');
        return p.substring(idx+1);
    }
Example 12
public void addSchema(final URL schemaURL) {
        assert(schemaURL != null);
        addSchema(schemaURL.getPath());
    }
Example 13
protected URLConnection openConnection(URL u) throws IOException {
        String x = u.getPath();
        x = x.replaceAll("___", ":");
        x = x.replaceAll("__", "!");
        return new URL(x).openConnection();
    }
Example 14
public File remove() {
    URL furl = null;
    if (isFile()) {
      furl = getURL();
      unCacheImage(furl);
      return new File(furl.getPath());
    }
    return null;
  }
Example 15
private URL base;

    private URI getURI(String uriPart) throws URISyntaxException {
        return new URI("ws://"
            + base.getHost()
            + ":"
            + base.getPort()
            + base.getPath()
            + uriPart);
    }
Example 16
public void removeServant(URL url) {
        UndertowHTTPHandler handler = registedPaths.remove(url.getPath());
        if (handler == null) {
            return;
        }
        --servantCount;
        if (url.getPath().isEmpty()) {
            return;
        }
        if (handler.isContextMatchExact()) {
            path.removeExactPath(url.getPath());
        } else {
            path.removePrefixPath(url.getPath());
        }
    }
Example 17
public static String getClientKeyStore() {
    URL keyStore = cclass.getClassLoader().getResource(getInstance().getProperty(KEY_CLIENT_KEY_STORE));
    return keyStore.getPath();
  }
Example 18
public void testFolderSlashUrl() throws Exception {
        URL u = getWriteFolder().toURL();
        assertTrue("invalid url of directory", u.getPath().endsWith("/"));
    }
Example 19
public static String getClientTrustStore() {
    URL trustStore = cclass.getClassLoader().getResource(getInstance().getProperty(KEY_CLIENT_TRUST_STORE));
    return trustStore.getPath();
  }
Example 20
protected boolean isJarURL(URL fileUrl) {
        Matcher jarMatcher = JAR_PATTERN.matcher(fileUrl.getPath());
        return jarMatcher.matches();
    }
Example 21
private File fileOf( String classpathResource )
    {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        URL resource = cl.getResource( classpathResource );

        File result = null;
        if ( resource != null )
        {
            result = new File( resource.getPath() );
        }

        return result;
    }
Example 22
private static String extractRelevantExtension(URL url) {
        String path = url.getPath();
        return extractRelevantExtension(path);
    }
Example 23
public String getFullPath(String filename) {
    URL url = Thread.currentThread().getContextClassLoader().getResource("certificates/" + filename);
    // can not get cert from jar
    if (url == null || url.getPath().contains("!")) {
      // get from env
      return System.getProperty(filename);
    }
    return url.getPath();
  }
Example 24
protected boolean equals( URL u1, URL u2 )
  {
    if( u1 == u2 )
    {
      return true;
    }
    if( u1 == null || u2 == null )
    {
      return false;
    }
    return (u1.getProtocol() + u1.getHost() + u1.getPath()).equals( u2.getProtocol() + u2.getHost() + u2.getPath() );
  }
Example 25
protected String getJavaResourceKey(URL resource) {
        String resourceText = resource.toString();
        if (resourceText.startsWith("jar:")) {
            return "jar:" + getJarPath(resource);
        } else {
            return resource.getPath();
        }
    }