List of usage examples for java.net URL toString
public String toString()
From source file:jp.aegif.nemaki.cmis.aspect.query.solr.SolrUtil.java
public String getSolrUrl() { String protocol = propertyManager.readValue(PropertyKey.SOLR_PROTOCOL); String host = propertyManager.readValue(PropertyKey.SOLR_HOST); int port = Integer.valueOf(propertyManager.readValue(PropertyKey.SOLR_PORT)); String context = propertyManager.readValue(PropertyKey.SOLR_CONTEXT); String url = null;/*from w ww.j a v a 2 s .c o m*/ try { URL _url = new URL(protocol, host, port, ""); url = _url.toString() + "/" + context + "/"; } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } log.info("Solr URL:" + url); return url; }
From source file:be.fedict.eid.idp.model.bean.AttributeServiceManagerBean.java
@SuppressWarnings("unchecked") public List<IdentityProviderAttributeType> getAttributeServiceTypes() { List<IdentityProviderAttributeType> attributeServices = new LinkedList<IdentityProviderAttributeType>(); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Enumeration<URL> resources; try {//from w w w .jav a 2 s .co m resources = classLoader.getResources("META-INF/eid-idp-attribute.xml"); } catch (IOException e) { LOG.error("I/O error: " + e.getMessage(), e); return attributeServices; } Unmarshaller unmarshaller; try { JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class); unmarshaller = jaxbContext.createUnmarshaller(); } catch (JAXBException e) { LOG.error("JAXB error: " + e.getMessage(), e); return attributeServices; } while (resources.hasMoreElements()) { URL resource = resources.nextElement(); LOG.debug("resource URL: " + resource.toString()); JAXBElement<IdentityProviderAttributesType> jaxbElement; try { jaxbElement = (JAXBElement<IdentityProviderAttributesType>) unmarshaller.unmarshal(resource); } catch (JAXBException e) { LOG.error("JAXB error: " + e.getMessage(), e); continue; } IdentityProviderAttributesType identityProviderAttributes = jaxbElement.getValue(); for (IdentityProviderAttributeType identityProviderAttribute : identityProviderAttributes .getIdentityProviderAttribute()) { attributeServices.add(identityProviderAttribute); } } return attributeServices; }
From source file:Dropper.java
/** * Do the actual import./*ww w . j ava 2s. c o m*/ * * @see javax.swing.TransferHandler#importData(javax.swing.JComponent, * java.awt.datatransfer.Transferable) */ public boolean importData(JComponent comp, Transferable t) { DataFlavor[] flavors = t.getTransferDataFlavors(); System.out.println("Trying to import:" + t); System.out.println("... which has " + flavors.length + " flavors."); for (int i = 0; i < flavors.length; i++) { DataFlavor flavor = flavors[i]; try { if (flavor.equals(DataFlavor.javaFileListFlavor)) { System.out.println("importData: FileListFlavor"); List l = (List) t.getTransferData(DataFlavor.javaFileListFlavor); Iterator iter = l.iterator(); while (iter.hasNext()) { File file = (File) iter.next(); System.out.println("GOT FILE: " + file.getCanonicalPath()); // Now do something with the file... } return true; } else if (flavor.equals(DataFlavor.stringFlavor)) { System.out.println("importData: String Flavor"); String fileOrURL = (String) t.getTransferData(flavor); System.out.println("GOT STRING: " + fileOrURL); try { URL url = new URL(fileOrURL); System.out.println("Valid URL: " + url.toString()); // Do something with the contents... return true; } catch (MalformedURLException ex) { System.err.println("Not a valid URL"); return false; } // now do something with the String. } else { System.out.println("importData rejected: " + flavor); // Don't return; try next flavor. } } catch (IOException ex) { System.err.println("IOError getting data: " + ex); } catch (UnsupportedFlavorException e) { System.err.println("Unsupported Flavor: " + e); } } // If you get here, I didn't like the flavor. Toolkit.getDefaultToolkit().beep(); return false; }
From source file:projavafx.videoplayer3.VideoPlayer3.java
@Override public void start(Stage primaryStage) { final Label message = new Label("I \u2764 Robots"); message.setVisible(false);/*from w w w .j a v a2 s. c o m*/ String workingDir = System.getProperty("user.dir"); final File f = new File(workingDir, "../media/omgrobots.flv"); final Media m = new Media(f.toURI().toString()); m.getMarkers().put("Split", Duration.millis(3000)); m.getMarkers().put("Join", Duration.millis(9000)); final MediaPlayer mp = new MediaPlayer(m); final MediaView mv1 = new MediaView(mp); mv1.setViewport(new Rectangle2D(0, 0, 960 / 2, 540)); StackPane.setAlignment(mv1, Pos.CENTER_LEFT); final MediaView mv2 = new MediaView(mp); mv2.setViewport(new Rectangle2D(960 / 2, 0, 960 / 2, 540)); StackPane.setAlignment(mv2, Pos.CENTER_RIGHT); StackPane root = new StackPane(); root.getChildren().addAll(message, mv1, mv2); root.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { mp.seek(Duration.ZERO); message.setVisible(false); } }); final Scene scene = new Scene(root, 960, 540); final URL stylesheet = getClass().getResource("media.css"); scene.getStylesheets().add(stylesheet.toString()); primaryStage.setScene(scene); primaryStage.setTitle("Video Player 3"); primaryStage.show(); mp.setOnMarker(new EventHandler<MediaMarkerEvent>() { @Override public void handle(final MediaMarkerEvent event) { Platform.runLater(new Runnable() { @Override public void run() { if (event.getMarker().getKey().equals("Split")) { message.setVisible(true); buildSplitTransition(mv1, mv2).play(); } else { buildJoinTransition(mv1, mv2).play(); } } }); } }); mp.play(); }
From source file:io.appium.java_client.service.local.AppiumDriverLocalService.java
private void ping(long time, TimeUnit timeUnit) throws UrlChecker.TimeoutException { URL url = getUrl(); try {/*ww w .j a va 2s . c om*/ URL status = new URL(url.toString() + "/status"); new UrlChecker().waitUntilAvailable(time, timeUnit, status); } catch (MalformedURLException e) { throw new RuntimeException( "There is something wrong with the URL " + url.toString().toString() + "/status"); } }
From source file:be.fedict.eid.idp.model.bean.ProtocolServiceManagerBean.java
@SuppressWarnings("unchecked") public List<IdentityProviderProtocolType> getProtocolServices() { List<IdentityProviderProtocolType> protocolServices = new LinkedList<IdentityProviderProtocolType>(); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Enumeration<URL> resources; try {/*w ww . ja v a2 s . co m*/ resources = classLoader.getResources("META-INF/eid-idp-protocol.xml"); } catch (IOException e) { LOG.error("I/O error: " + e.getMessage(), e); return protocolServices; } Unmarshaller unmarshaller; try { JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class); unmarshaller = jaxbContext.createUnmarshaller(); } catch (JAXBException e) { LOG.error("JAXB error: " + e.getMessage(), e); return protocolServices; } while (resources.hasMoreElements()) { URL resource = resources.nextElement(); LOG.debug("resource URL: " + resource.toString()); JAXBElement<IdentityProviderProtocolsType> jaxbElement; try { jaxbElement = (JAXBElement<IdentityProviderProtocolsType>) unmarshaller.unmarshal(resource); } catch (JAXBException e) { LOG.error("JAXB error: " + e.getMessage(), e); continue; } IdentityProviderProtocolsType identityProviderProtocols = jaxbElement.getValue(); for (IdentityProviderProtocolType identityProviderProtocol : identityProviderProtocols .getIdentityProviderProtocol()) { protocolServices.add(identityProviderProtocol); } } return protocolServices; }
From source file:com.cloudbees.mtslaves.client.RemoteReference.java
protected RemoteReference(URL url, Credential token) { try {//w w w. j a v a 2 s . c o m if (!url.toString().endsWith("/")) url = new URL(url.toExternalForm() + '/'); // normalize } catch (MalformedURLException e) { throw new IllegalArgumentException("Invalid URL:" + url, e); } this.url = url; this.token = token; }
From source file:cc.recommenders.io.IoUtilsTest.java
@Test public void randomDirIsSubfolderOfTmp() throws IOException { URL actual = sut.getRandomTempDirectory().getUrl(); URL expected = File.createTempFile(IoUtils.TEMP_PREFIX, "").toURI().toURL(); int len = expected.toString().indexOf(IoUtils.TEMP_PREFIX); String actual2 = actual.toString().substring(0, len); String expected2 = expected.toString().substring(0, len); assertEquals(expected2, actual2);//from w ww . j a va 2 s . c om }
From source file:org.jboss.additional.testsuite.jdkall.present.security.roleToRolesMapping.RoleToRolesMappingTestCase.java
@Test public void roleToRolesMappingServletTest(@ArquillianResource URL url) throws Exception { URL testURL = new URL(url.toString() + "JMSClientServlet"); System.out.println(testURL + "............."); //successful authentication and authorization assertEquals("Response body is not correct.", JMSClientServlet.RESPONSE_BODY, Utils.makeCallWithBasicAuthn(testURL, "username", "password", 200)); // final HttpGet request = new HttpGet(testURL.toString()); // CloseableHttpClient httpClient = HttpClientBuilder.create().build(); // CloseableHttpResponse response = null; try {//from w w w . ja v a2 s . c o m // response = httpClient.execute(request); // System.out.println("Response : " + response.toString()); } catch (Exception e) { e.printStackTrace(); fail(); } finally { // IOUtils.closeQuietly(response); // httpClient.close(); Thread.sleep(1000); String path = this.getClass().getClassLoader().getResource("").getPath(); FileInputStream inputStream = new FileInputStream(path + "../" + serverLogPath); try { String everything = IOUtils.toString(inputStream); assertFalse("Autorization has failed ... ", everything.contains("MessageMDBSample is not allowed")); } finally { inputStream.close(); } } }
From source file:MainClass.java
public void showDocument(URL url, String frame) { try {//from w ww. j a va 2 s . com showDocument(new URL(url.toString() + frame)); } catch (MalformedURLException e) { } }