Refine search
public java.net.URL toJavaURL() { try { return new java.net.URL(toString()); } catch (MalformedURLException e) { throw new IllegalStateException(e.getMessage(), e); } }
/** * @param file file to handle * @param depth recursion depth * @param results collection * {@inheritDoc} */ protected void handleFile(File file, int depth, Collection results) { try { // Looks Strange, but is actually recommended over just .URL() results.add(file.toURI().toURL()); } catch (MalformedURLException e) { log.debug("MalformedURLException" + e.getMessage()); } }
private String getResourceUrlString(String resource) { URL url = null; try { if (resource.startsWith("http") || resource.startsWith("file")) { url = new URL(resource); } else { url = new File(resource).toURI().toURL(); } } catch (MalformedURLException ex) { logger.log(Level.WARNING, "Failed to determine URL of " + resource + ". Reason: " + ex.getMessage()); logger.log(Level.FINER, "Details: ", ex); } return url != null ? url.toString() : null; }
public java.net.URL toJavaURL() { try { return new java.net.URL(toString()); } catch (MalformedURLException e) { throw new IllegalStateException(e.getMessage(), e); } }
jarUrl = new URL( file ); if ( "file".equals( jarUrl.getProtocol() ) ) { if ( file.indexOf( ' ' ) != -1 ) { jarUrl = new File( jarUrl.getFile() ).toURI().toURL(); jarUrl = new File(file).toURI().toURL(); jarUrl = new URL( protocol, url.getHost(), url.getPort(), file ); "Unable to determine JAR Url from " + url + ". Cause: " + e.getMessage() );
public void addJars(List<String> dirs) { for (String dir : dirs) { try { myloader.addJar(Paths.get(dir).toUri().toURL()); } catch (MalformedURLException e) { logger.error(e.getMessage()); } } }
private URL toURL(String urlStr) { try { return new URL(urlStr); } catch (MalformedURLException ex) { throw new IllegalArgumentException("Unable to convert '" + urlStr + "' to URL: " + ex.getMessage(), ex); } } }
/** * Get the pathname to the webapps files. * @param appName eg "secondary" or "datanode" * @return the pathname as a URL * @throws FileNotFoundException if 'webapps' directory cannot be found * on CLASSPATH or in the development location. */ protected String getWebAppsPath(String appName) throws FileNotFoundException { URL resourceUrl = null; File webResourceDevLocation = new File("src/main/webapps", appName); if (webResourceDevLocation.exists()) { LOG.info("Web server is in development mode. Resources " + "will be read from the source tree."); try { resourceUrl = webResourceDevLocation.getParentFile().toURI().toURL(); } catch (MalformedURLException e) { throw new FileNotFoundException("Mailformed URL while finding the " + "web resource dir:" + e.getMessage()); } } else { resourceUrl = getClass().getClassLoader().getResource("webapps/" + appName); if (resourceUrl == null) { throw new FileNotFoundException("webapps/" + appName + " not found in CLASSPATH"); } } String urlString = resourceUrl.toString(); return urlString.substring(0, urlString.lastIndexOf('/')); }
private static URL toURL(String url) { try { return new URL(url); } catch (MalformedURLException ex) { throw new IllegalArgumentException("Invalid JWK Set URL \"" + url + "\" : " + ex.getMessage(), ex); } }
private URL calculateImageUrl() { if (typ == ImportTyp.DIR) { try { return imageFiles[currentPos - 1].toURI().toURL(); } catch (MalformedURLException e1) { } } URL startUrl = null; if (typ == ImportTyp.SHAPE) startUrl = shapeFileUrl; if (typ == ImportTyp.CSV) startUrl = csvFileURL; String path = startUrl.getPath(); int index = path.lastIndexOf('/'); String imagePath = null; if (index == -1) { imagePath = currentLocation; } else { imagePath = path.substring(0, index + 1) + currentLocation; } try { return new URL( startUrl.getProtocol(), startUrl.getHost(), startUrl.getPort(), imagePath); } catch (MalformedURLException e) { logError(e, e.getMessage()); return null; } }
/** * 扫描文件 * * @param baseDir * @return */ protected Enumeration<URL> urlSolve(String baseDir) { if (isAbsolutePath) { try { if (!baseDir.contains("/") && baseDir.contains(".")) { baseDir = baseDir.replaceAll("\\.", "/"); } File file = new File(baseDir); return Collections.enumeration(Lister.<URL>of(file.toURI().toURL())); } catch (MalformedURLException e) { logger.error(e.getMessage(), e); } } else { super.urlSolve(baseDir); } return null; } }
/** * Maps {@code stringValue} to {@code URL}. * * @param stringValue source value as a {@code String} * @return mapped {@code stringValue} to {@code URL} */ public static URL toUrl(String stringValue) { try { return new URL(stringValue); } catch (MalformedURLException e) { throw new IllegalArgumentException(e.getMessage(), e); } }
protected void logRequest(ComponentLog logger, URI endpoint, GenericApiGatewayRequest request) { try { logger.debug("\nRequest to remote service:\n\t{}\t{}\t\n{}", new Object[]{endpoint.toURL().toExternalForm(), request.getHttpMethod(), getLogString(request.getHeaders())}); } catch (MalformedURLException e) { logger.debug(e.getMessage()); } }
/** * Creates a new instance using the provided URLs as the location for the JWK Sets. * * @param jwkSetUrls the JWK Set URLs */ JwkDefinitionSource(List<String> jwkSetUrls) { this.jwkSetUrls = new ArrayList<URL>(); for(String jwkSetUrl : jwkSetUrls) { try { this.jwkSetUrls.add(new URL(jwkSetUrl)); } catch (MalformedURLException ex) { throw new IllegalArgumentException("Invalid JWK Set URL: " + ex.getMessage(), ex); } } }
} else { try { URL testURI = getUri().toURL(); if (testURI == null) throw new MalformedURLException(); getClass(), "uri", "URL must be valid: " + ex.getMessage()) ); } catch (IllegalArgumentException ex) {
private static URI validateIssuer(String issuer) throws URISyntaxException { try { new URL(issuer); } catch (MalformedURLException x) { throw new URISyntaxException(issuer, x.getMessage()); } return new URI(issuer); }
private URL encodeAnnounceToURL(AnnounceRequestMessage.RequestEvent event, AnnounceableInformation torrentInfo, Peer peer) throws AnnounceException { URL result; try { HTTPAnnounceRequestMessage request = this.buildAnnounceRequest(event, torrentInfo, peer); result = request.buildAnnounceURL(this.tracker.toURL()); } catch (MalformedURLException mue) { throw new AnnounceException("Invalid announce URL (" + mue.getMessage() + ")", mue); } catch (MessageValidationException mve) { throw new AnnounceException("Announce request creation violated " + "expected protocol (" + mve.getMessage() + ")", mve); } catch (IOException ioe) { throw new AnnounceException("Error building announce request (" + ioe.getMessage() + ")", ioe); } return result; }
@Override public URL convert(String s) throws IllegalArgumentException { try { return new URL(StringUtils.removeTrailingSlash(s)); } catch (MalformedURLException e) { throw new IllegalArgumentException(e.getMessage()); } }
protected void logResponse(ComponentLog logger, GenericApiGatewayResponse response) { try { logger.debug("\nResponse from remote service:\n\t{}\n{}", new Object[]{response.getHttpResponse().getHttpRequest().getURI().toURL().toExternalForm(), getLogString(response.getHttpResponse().getHeaders())}); } catch (MalformedURLException e) { logger.debug(e.getMessage()); } }