List of usage examples for java.net URL toString
public String toString()
From source file:org.coffeebreaks.validators.jsonlint.JsonlintValidator.java
ValidationResult validateUri(URL url, ValidationRequest request) throws IOException { return validate(url.toString(), request); }
From source file:org.jboss.additional.testsuite.jdkall.present.web.servlet.headers.CookieHeaderServletTestCase.java
@Test @Ignore/*from w ww . ja v a2 s. co m*/ @OperateOnDeployment(DEPLOYMENT2) public void cookieHeaderCommaSeparatorTest(@ArquillianResource URL url2) throws Exception { URL testURL = new URL(url2.toString() + "cookieHeaderServlet2"); CloseableHttpClient httpClient = HttpClients.createDefault(); final HttpGet request = new HttpGet(testURL.toString()); CloseableHttpResponse response = null; response = httpClient.execute(request); response = httpClient.execute(request); Assert.assertTrue("The cookie length should be 2.", response.getFirstHeader("cookies.length").getValue().compareTo("2") == 0); Assert.assertTrue("The cookie value1 should be example_cookie.", response.getFirstHeader("cookies.value1").getValue().compareTo("example_cookie") == 0); Assert.assertTrue("The cookie value2 should be example2_cookie.", response.getFirstHeader("cookies.value2").getValue().compareTo("example2_cookie") == 0); IOUtils.closeQuietly(response); httpClient.close(); }
From source file:com.wavemaker.commons.io.ResourceURLTest.java
@Test public void shouldGetFolderURL() throws Exception { URL url = ResourceURL.get(this.root.getFolder("/jail/a/b")); assertThat(url.toString(), Matchers.is(Matchers.equalTo("rfs:/jail/a/b/"))); }
From source file:com.cuubez.visualizer.scanner.ClassScanner.java
private FileReader getFileReader(URL url, com.cuubez.visualizer.scanner.filter.FileFilter filter) throws IOException { String urlString = url.toString(); if (urlString.endsWith("!/")) { urlString = urlString.substring(4); urlString = urlString.substring(0, urlString.length() - 2); url = new URL(urlString); }//from w w w .j a v a 2s . c o m if (!urlString.endsWith("/")) { return new JarFileReader(url.openStream(), filter); } else { if (!url.getProtocol().equals("file")) { throw new IOException("Unable to understand protocol: " + url.getProtocol()); } File f = new File(url.getPath()); if (f.isDirectory()) { return new ClassFileReader(f, filter); } else { return new JarFileReader(url.openStream(), filter); } } }
From source file:org.springframework.cloud.config.server.environment.HttpClientConfigurableHttpConnectionFactory.java
@Override public HttpConnection create(URL url, Proxy proxy) throws IOException { return new HttpClientConnection(url.toString(), null, lookupHttpClientBuilder(url).build()); }
From source file:edu.infsci2560.models.Course.java
/** * @param set the courseLink// w w w. ja v a 2s .c o m */ public void setCourseLink(URL courseLink) { //throws IOException { try { String stringUrl = courseLink.toString(); stringUrl = stringUrl.replaceAll(java.util.regex.Pattern.quote("watch?v="), "embed/"); URL newCourseLink = new URL(stringUrl); this.courseLink = newCourseLink; } catch (IOException e) { throw new RuntimeException(e); } // this.courseLink = courseLink; }
From source file:client.lib.Client.java
private Response request(OkHttpClient client, URL url) { Response response = null;/*from www. j a v a 2 s .c o m*/ try { System.out.println(client.getProtocols().get(0) + " => " + url.toString()); Request request = new Request.Builder().url(url.toString()).build(); response = client.newCall(request).execute(); System.out.println("> " + response.code() + " " + response.protocol()); } catch (ConnectException e) { System.out.println("ConnectException: " + e.getMessage()); } catch (IOException e) { System.out.println("IOException: " + e.getMessage()); } return response; }
From source file:com.sshtools.common.ui.ResourceIcon.java
/** * * * @param imageName// ww w. j av a 2 s .co m */ protected void loadImage(String imageName) { Image image = null; URL url = cls.getResource(imageName); if (url != null) { log.debug(url.toString()); image = Toolkit.getDefaultToolkit().getImage(url); } else { try { if (System.getSecurityManager() != null) { AccessController.checkPermission(new FilePermission(imageName, "read")); } image = Toolkit.getDefaultToolkit().getImage(imageName); } catch (AccessControlException ace) { log.error("Icon " + imageName + " could not be located as a " + "resource, and the current security manager will not " + "allow checking for a local file."); } } if (image != null) { this.setImage(image); } }
From source file:com.wavemaker.commons.io.ResourceURLTest.java
@Test public void shouldGetFileURL() throws Exception { URL url = ResourceURL.get(this.root.getFile("/jail/a/b/c.txt")); assertThat(url.toString(), Matchers.is(Matchers.equalTo("rfs:/jail/a/b/c.txt"))); }
From source file:fr.cls.atoll.motu.library.cas.util.AssertionUtils.java
/** * Checks for cas ticket./*from www .j a v a 2 s. c o m*/ * * @param targetService the target service * @return true, if successful */ public static boolean hasCASTicket(URL targetService) { return hasCASTicket(targetService.toString()); }