Example usage for java.net URL toString

List of usage examples for java.net URL toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Constructs a string representation of this URL .

Usage

From source file:com.adaptris.core.management.jetty.FromXmlConfig.java

private InputStream open(String urlString) throws Exception {
    final URL url = createUrlFromString(urlString);
    log.trace("Connecting to configured URL {}", url.toString());
    return url.openConnection().getInputStream();
}

From source file:com.wavemaker.commons.io.ResourceURLTest.java

@Test
public void shouldCreateRelativeToFile() throws Exception {
    Folder jail = this.root.getFolder("jail").jail();
    URL abc = ResourceURL.get(jail.getFile("a/b/c.txt"));
    URL url = new URL(abc, "/x/y/z.txt");
    assertThat(url.toString(), Matchers.is(Matchers.equalTo("rfs:/x/y/z.txt")));
    assertThat(IOUtils.toString(url.openStream()), Matchers.is(Matchers.equalTo("z")));
}

From source file:ru.histone.HistoneApiTest.java

@Before
public void init() {
    builder = new HistoneBuilder();
    builder.setResourceLoader(new DefaultResourceLoader());

    String relativePath = "relative_urls/template.tpl";
    URL resource = this.getClass().getClassLoader().getResource(relativePath);
    Assert.notNull(resource);/*from  w w w  .ja  v a2 s.c o  m*/

    String fullPath = resource.toString();
    resourcesFolderPath = fullPath.substring(0, fullPath.indexOf(relativePath));
}

From source file:com.norconex.commons.lang.url.QueryString.java

/**
 * Default URL character encoding is UTF-8.  
 * @param urlWithQueryString a URL from which to extract a query string.
 *///from w w w. j a  va  2 s  . c  o m
public QueryString(URL urlWithQueryString) {
    this(urlWithQueryString.toString(), null);
}

From source file:MiniBrowser.java

private void actionBack() {
    URL currentUrl = displayEditorPane.getPage();
    int pageIndex = pageList.indexOf(currentUrl.toString());
    try {//from  www .j a va2  s  .  c  o  m
        showPage(new URL((String) pageList.get(pageIndex - 1)), false);
    } catch (Exception e) {
    }
}

From source file:MiniBrowser.java

private void actionForward() {
    URL currentUrl = displayEditorPane.getPage();
    int pageIndex = pageList.indexOf(currentUrl.toString());
    try {/*from w ww .  jav  a  2 s .c  om*/
        showPage(new URL((String) pageList.get(pageIndex + 1)), false);
    } catch (Exception e) {
    }
}

From source file:dip.world.variant.VariantManager.java

/** Returns the "file" part of the URL; e.g.: x/y/z.jar, returns z.jar */
private static String getFile(URL url) {
    String s = url.toString();
    return s.substring(s.lastIndexOf("/") + 1, s.length());
}

From source file:interactivenetworksmathematica.TopologyHandler.java

public String getStringFromURL(URL url) {
    try {/*from w w w .  j a  va  2  s  .  com*/
        System.out.print("getting url: " + url.toString());
        return Request.Get(url.toString()).execute().returnContent().toString();
    } catch (ClientProtocolException ex) {
        Logger.getLogger(TopologyHandler.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(TopologyHandler.class.getName()).log(Level.SEVERE, null, ex);
    }

    return "";
}

From source file:com.zxy.commons.web.utils.URLPropertiesUtils.java

private String getWebInfPath() {
    URL url = getClass().getProtectionDomain().getCodeSource().getLocation();
    String path = url.toString();
    int index = path.indexOf("WEB-INF");

    if (index == -1) {
        index = path.indexOf("classes");
    }//from w ww .ja va  2s. c o m

    if (index == -1) {
        index = path.indexOf("bin");
    }

    if (index != -1) {
        path = path.substring(0, index);

        if (path.startsWith("zip")) {// classwarzip:D:/...
            path = path.substring(4);
        } else if (path.startsWith("file")) {// classclassfile:/D:/...
            path = path.substring(6);
        } else if (path.startsWith("jar")) {// classjar?jar:file:/D:/...
            path = path.substring(10);
        }
        return path.replace("/target", "");
    }
    return null;
}

From source file:com.partnet.page.HtmlTestPage.java

@Override
public void ready() {
    // typically this isn't the way to get to a real site
    // however, for this basic test this is the way to accomplish this.

    URL htmlPath = TestHtmlView.class.getClassLoader().getResource("TestHtml.html");

    webDriver.get(htmlPath.toString());
}