URL toString - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for URL toString method.

This code example shows how to use the following methods:toString
    /** 
     * {@inheritDoc} 
     */ 
    @Override 
    public String toString() {
        return path.toString();
    } 
 
    /** 
     * Returns base URL 
     * 
     * @return base URL 
     */ 
    public URL path() {
        return path;
    } 
 
    /** 
     * Returns read buffer size 
     * 
8
CodeRank
This code example shows how to use the following methods:toString
    } 
  } 
   
  @Test 
  public void shouldBeAbleToCreateAWebDriverBackedSeleniumInstance() throws MalformedURLException { 
    URL wdServer = new URL(String.format("http://%s:%d/wd/hub", url.getHost(), url.getPort()));
    WebDriver driver = new RemoteWebDriver(wdServer, DesiredCapabilities.firefox());
    Capabilities capabilities = ((HasCapabilities) driver).getCapabilities();
 
    DefaultSelenium selenium = new DefaultSelenium(
        url.getHost(), url.getPort(), "*webdriver", root);
 
    try { 
      selenium.start(capabilities);
      selenium.open(wdServer.toString());
 
      String seleniumTitle = selenium.getTitle();
      String title = driver.getTitle();
 
      assertEquals(title, seleniumTitle);
8
CodeRank
This code example shows how to use the following methods:toString
            boolean mode) {
        String modeString = (mode ? "folders" : "files");
 
        URL url = null;
        try { 
            url = new URL(SCRIPT_URL +
                    "?path=" + dirRelativePath +
                    "&recurse=" + recurse +
                    "&mode=" + modeString);
        } catch (MalformedURLException e) {
            Log.e(LOG_TAG, "path=" + dirRelativePath + " recurse=" + recurse + " mode=" +
                    modeString, e);
            return new LinkedList<String>();
        } 
 
        HttpGet httpRequest = new HttpGet(url.toString());
        ResponseHandler<LinkedList<String>> handler = new ResponseHandler<LinkedList<String>>() {
            @Override 
            public LinkedList<String> handleResponse(HttpResponse response)
                    throws IOException { 
                LinkedList<String> lines = new LinkedList<String>();
8
CodeRank
This code example shows how to use the following methods:toString
                + "    <test:setState>" 
                + "      <arg0>Foo</arg0>" 
                + "    </test:setState>" 
                + "  </soapenv:Body>" 
                + "</soapenv:Envelope>"; 
        URL webRoot = new URL(baseUrl, "/");
        String result = HttpRequest.post(webRoot.toString() + "ejbws-example/SingletonEndpoint", message, 10, SECONDS);
        // TODO: check something 
        System.out.println(result);
    } 
 
    @Test 
    public void testSingletonWSDL() throws Exception { 
        URL webRoot = new URL(baseUrl, "/");
        final String wsdl = HttpRequest.get(webRoot.toString() + "ejbws-example/SingletonEndpoint?wsdl", 10, SECONDS);
        // TODO: check something 
        System.out.println(wsdl);
    } 
 
} 
8
CodeRank
This code example shows how to use the following methods:toExternalForm, toString
 
    public GeoRSSReader createReader(final URL url, final String username, final String password)
            throws IOException { 
 
        if (log.isDebugEnabled()) {
            log.debug("Creating GeoRSS reader for URL " + url.toExternalForm() + " with user "
                    + username);
        } 
 
        HttpClientBuilder builder = new HttpClientBuilder();
        builder.setHttpCredentials(username, password, url);
        builder.setBackendTimeout(120);
 
        HttpClient httpClient = builder.buildClient();
 
        GetMethod getMethod = new GetMethod(url.toString());
        if (builder.isDoAuthentication()) {
            getMethod.setDoAuthentication(true);
            httpClient.getParams().setAuthenticationPreemptive(true);
        } 

7
CodeRank
This code example shows how to use the following methods:toString
	private void populatePropertiesURLFromClassURL() { 
		if (propertiesURL == null && classURL != null) {
			final String path = classURL.toString().replaceFirst("\\" + CLASS_EXTENSION, PROPERTIES_EXTENSION);
 
			try { 
				propertiesURL = new URL(path);
			} catch (MalformedURLException e) {
				Logger.logError(e);
			} 
			if (isInvalidURL(propertiesURL)) {
				propertiesURL = null;
			} 
		} 
	} 
 
	private void populateClassURLFromPropertiesURL() { 
		if (classURL == null && propertiesURL != null) {
			final String path = propertiesURL.toString().replaceAll("\\" + PROPERTIES_EXTENSION, CLASS_EXTENSION);
 
			try { 

7
CodeRank
This code example shows how to use the following methods:toString
 
        return war;
    } 
 
    private static String performCall(String urlPattern, String param) throws Exception {
        return HttpRequest.get(baseUrl.toString() + urlPattern + "?input=" + param, 10, SECONDS);
    } 
 
    @Test 
    public void testEcho() throws Exception { 
        String result = performCall("simple", "Hello+world");
        assertEquals("0", result);
 
        result = performCall("simple", "Hello+world");
        assertEquals("0", result);
    } 
} 
7
CodeRank
This code example shows how to use the following methods:toString
		return war;
	} 
 
	private static String performCall(String urlPattern, String param)
			throws Exception { 
		return HttpRequest.get(baseUrl.toString() + urlPattern + "?mode=" + param, 20, SECONDS);
	} 
 
	@Test 
	public void testReadWrite() throws Exception { 
		performCall("test", "write"); 
 
		String result = performCall("test", "read");
		assertEquals("Flight number one", result);
	} 
 
} 
7
CodeRank
This code example shows how to use the following methods:toString
    @ArquillianResource 
    @OperateOnDeployment(depName)
    static URL url;
     
    private static String performCall(String urlPattern) throws Exception {
        return HttpRequest.get(url.toString() + urlPattern, 5, TimeUnit.SECONDS);
    } 
 
    @Test 
    @InSequence(1) 
    public void testJaxRsWithNoApplication() throws Exception { 
        String result = performCall("myjaxrs/jsapi");
        Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><customer><first>John</first><last>Citizen</last></customer>", result);
    } 
 
    @Test 
    @InSequence(2) 
    public void testJaxRsJSApis() throws Exception { 
        String result = performCall("/rest-JS");
        Assert.assertTrue(result.contains("var CustomerResource"));
7
CodeRank
This code example shows how to use the following methods:openConnection, toString, toURI
 
        ProxySelector proxySelector = ProxySelector.getDefault();
        if (proxySelector != null) {
            URI uri;
            try { 
                uri = url.toURI();
            } catch (URISyntaxException e) {
                IOException ioe = new IOException(url.toString());
                ioe.initCause(e);
                throw ioe;
            } 
 
            List<Proxy> proxies = proxySelector.select(uri);
            if (proxies != null && !proxies.isEmpty()) {
                proxy = proxies.get(0);
            } 
        } 
 
        return url.openConnection(proxy);
    } 

6
CodeRank

Related URL toString Questions & Answers:

toString Method Overview
Constructs a string representation of this URL.
See Code Examples for other Java 8 URL Methods: