List of usage examples for java.net URL toString
public String toString()
From source file:com.florianmski.tracktoid.image.Fanart.java
private synchronized void loadData(URL url, Context c) { try {/* w w w .j a v a 2s . co m*/ HttpUriRequest request = new HttpGet(url.toString()); request.addHeader("Accept-Encoding", "gzip"); res = http.execute(request); } catch (IOException e) { Log.e("FanartParser", "Error loading data", e); } try { //using special encoding to reduce download time InputStream instream = res.getEntity().getContent(); Header contentEncoding = res.getFirstHeader("Content-Encoding"); if (contentEncoding != null && contentEncoding.getValue().equalsIgnoreCase("gzip")) instream = new GZIPInputStream(instream); xr.parse(new InputSource(instream)); } catch (Exception e) { Log.e("FanartParser", "Error parsing data", e); } }
From source file:com.android.tests.lib.LibUnitTest.java
@Test public void onlyOneMockableJar() throws Exception { URL[] urls = ((URLClassLoader) getClass().getClassLoader()).getURLs(); int count = 0; URL mockableJar = null;//w ww. j ava 2 s. c o m for (URL u : urls) { if (u.toString().contains("mockable-")) { count++; mockableJar = u; } } assertEquals(1, count); assertNotNull(mockableJar); assertTrue(mockableJar.toString().contains("mockable-android-19.jar")); }
From source file:net.sf.jabref.gui.entryeditor.SimpleUrlDragDrop.java
@Override public void drop(DropTargetDropEvent event) { Transferable tsf = event.getTransferable(); event.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); //try with an URL DataFlavor dataFlavor = null; try {/*from ww w. ja va 2s. co m*/ dataFlavor = new DataFlavor("application/x-java-url; class=java.net.URL"); } catch (ClassNotFoundException e) { LOGGER.warn("Could not find DropTargetDropEvent class", e); } try { URL url = (URL) tsf.getTransferData(dataFlavor); //insert URL editor.setText(url.toString()); storeFieldAction.actionPerformed(new ActionEvent(editor, 0, "")); } catch (UnsupportedFlavorException nfe) { // if not an URL JOptionPane.showMessageDialog((Component) editor, Localization.lang("Operation not supported"), Localization.lang("Drag and Drop Error"), JOptionPane.ERROR_MESSAGE); LOGGER.warn("Could not perform drage and drop", nfe); } catch (IOException ioex) { LOGGER.warn("Could not perform drage and drop", ioex); } }
From source file:org.apache.cxf.fediz.service.idp.beans.TrustedIdpProtocolAction.java
public String mapSignInRequest(RequestContext requestContext) { String trustedIdpRealm = requestContext.getFlowScope().getString("whr"); LOG.info("Prepare redirect to Trusted IDP '{}'", trustedIdpRealm); Idp idpConfig = (Idp) WebUtils.getAttributeFromFlowScope(requestContext, IDP_CONFIG); TrustedIdp trustedIdp = idpConfig.findTrustedIdp(trustedIdpRealm); if (trustedIdp == null) { LOG.error("TrustedIdp '{}' not configured", trustedIdpRealm); throw new IllegalStateException("TrustedIdp '" + trustedIdpRealm + "'"); }//from w w w . j a v a 2s . c om String protocol = trustedIdp.getProtocol(); LOG.debug("TrustedIdp '{}' supports protocol {}", trustedIdpRealm, protocol); TrustedIdpProtocolHandler protocolHandler = trustedIdpProtocolHandlers.getProtocolHandler(protocol); if (protocolHandler == null) { LOG.error("No ProtocolHandler found for {}", protocol); throw new IllegalStateException("No ProtocolHandler found for '" + protocol + "'"); } URL redirectUrl = protocolHandler.mapSignInRequest(requestContext, idpConfig, trustedIdp); LOG.info("Redirect url {}", redirectUrl.toString()); return redirectUrl.toString(); }
From source file:com.comcast.cim.rest.client.xhtml.RequestBuilder.java
/** * Constructs a GET request used to follow a link. * @param a The <a> tag in a parsed response body that * is the link we want to follow.//w w w .ja v a 2 s. c om * @param context The URL used to retrieve the current * application state (parsed response body), needed so we * can properly interpret relative URLs. * @return {@link HttpUriRequest} * @throws MalformedURLException if the @href attribute of * the tag cannot be combined with the current URL context * to form a valid URL. */ public HttpUriRequest followLink(Element a, URL context) throws MalformedURLException { if (!"a".equalsIgnoreCase(a.getName())) { throw new IllegalArgumentException("can only follow links on <a> tags"); } String href = a.getAttributeValue("href"); if (href == null) { throw new IllegalArgumentException("<a> tag had no @href attribute"); } URL derived = new URL(context, href); return new HttpGet(derived.toString()); }
From source file:com.thoughtworks.go.domain.materials.tfs.TfsSDKCommandBuilder.java
private void explodeNatives() throws IOException { URL urlOfJar = getJarURL(); LOGGER.info("[TFS SDK] Exploding natives from {} to folder {}", urlOfJar.toString(), tempFolder.getAbsolutePath()); JarInputStream jarStream = new JarInputStream(urlOfJar.openStream()); JarEntry entry;/* w w w . ja v a 2 s . c o m*/ while ((entry = jarStream.getNextJarEntry()) != null) { if (!entry.isDirectory() && entry.getName().startsWith("tfssdk/native/")) { File newFile = new File(tempFolder, entry.getName()); newFile.getParentFile().mkdirs(); LOGGER.info("[TFS SDK] Extract {} -> {}", entry.getName(), newFile); try (OutputStream fos = new FileOutputStream(newFile)) { IOUtils.copy(jarStream, fos); } } } }
From source file:brooklyn.rest.client.BrooklynApi.java
public BrooklynApi(URL endpoint, String username, String password) { this(endpoint.toString(), username, password); }
From source file:com.bez4pieci.cookies.Cookies.java
public void setCookie(String action, JSONArray args, CallbackContext callbackContext) { Log.v(TAG, "Setting cookie"); if (args.length() == 0) { System.err.println("Exception: No Arguments passed"); } else {/* ww w . jav a2s .c om*/ try { JSONObject options = args.getJSONObject(0); String protocol = DEFAULT_PROTOCOL; String host = null; int port = DEFAULT_PORT; String path = null; // Set the protocol if (options.has("protocol")) { protocol = options.getString("protocol"); } // Set the domain/host if (options.has("domain")) { host = options.getString("domain"); } else if (options.has("host")) { host = options.getString("host"); } // Set the port if (options.has("port")) { port = options.getInt("port"); } // Set the file/path if (options.has("file")) { path = options.getString("file"); } else if (options.has("path")) { path = options.getString("path"); } URL url = new URL(protocol, host, port, path); CookieManager.getInstance().setCookie(url.toString(), options.optString("value")); } catch (JSONException e) { Log.e(TAG, "Exception while setting cookie", e); } catch (MalformedURLException e) { Log.e(TAG, "Exception while setting cookie", e); } } }
From source file:com.icesoft.jsfmeta.MetadataXmlParser.java
public void register(String publicId, URL entityURL) { digester.register(publicId, entityURL.toString()); }