Java Code Examples for java.net.URL#toString()
The following examples show how to use
java.net.URL#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonSlurper.java From groovy with Apache License 2.0 | 6 votes |
private Object parseURL(URL url, Map params, String charset) { Reader reader = null; try { if (params == null || params.isEmpty()) { reader = ResourceGroovyMethods.newReader(url, charset); } else { reader = ResourceGroovyMethods.newReader(url, params, charset); } return parse(reader); } catch (IOException ioe) { throw new JsonException("Unable to process url: " + url.toString(), ioe); } finally { if (reader != null) { DefaultGroovyMethodsSupport.closeWithWarning(reader); } } }
Example 2
Source File: RealS3Client.java From wecube-platform with Apache License 2.0 | 6 votes |
@Override public String uploadFile(String bucketName, String s3KeyName, File file) { if (!(s3Client.doesBucketExist(bucketName))) { s3Client.createBucket(new CreateBucketRequest(bucketName)); } if (fileExists(bucketName, s3KeyName)) { throw new WecubeCoreException(String.format("File[%s] already exists", s3KeyName)); } s3Client.putObject(new PutObjectRequest(bucketName, s3KeyName, file).withCannedAcl(CannedAccessControlList.Private)); GeneratePresignedUrlRequest urlRequest = new GeneratePresignedUrlRequest(bucketName, s3KeyName); URL url = s3Client.generatePresignedUrl(urlRequest); log.info("uploaded File [{}] to S3. url = [{}]", file.getAbsolutePath(), url); return url.toString(); }
Example 3
Source File: ImageDestinationProcessorRelativeToAbsolute.java From Markwon with Apache License 2.0 | 6 votes |
@NonNull @Override public String process(@NonNull String destination) { String out = destination; if (base != null) { try { final URL u = new URL(base, destination); out = u.toString(); } catch (MalformedURLException e) { e.printStackTrace(); } } return out; }
Example 4
Source File: LinkFilter.java From ache with Apache License 2.0 | 6 votes |
public boolean accept(URL link) { String url = link.toString(); String domain = LinkRelevance.getTopLevelDomain(link.getHost()); TextMatcher hostWhitelist = hostsWhitelists.get(domain); if (hostWhitelist != null && !hostWhitelist.matches(url)) { return false; } TextMatcher hostBlacklist = hostsBlacklists.get(domain); if (hostBlacklist != null && !hostBlacklist.matches(url)) { return false; } if (whitelist != null && !whitelist.matches(url)) { return false; } if (blacklist != null && !blacklist.matches(url)) { return false; } return true; }
Example 5
Source File: SVGGlyphLoader.java From JFoenix with Apache License 2.0 | 6 votes |
/** * load a single svg icon from a file * * @param url of the svg icon * @return SVGGLyph node * @throws IOException */ public static SVGGlyph loadGlyph(URL url) throws IOException { String urlString = url.toString(); String filename = urlString.substring(urlString.lastIndexOf('/') + 1); int startPos = 0; int endPos = 0; while (endPos < filename.length() && filename.charAt(endPos) != '-') { endPos++; } int id = Integer.parseInt(filename.substring(startPos, endPos)); startPos = endPos + 1; while (endPos < filename.length() && filename.charAt(endPos) != '.') { endPos++; } String name = filename.substring(startPos, endPos); return new SVGGlyph(id, name, extractSvgPath(getStringFromInputStream(url.openStream())), Color.BLACK); }
Example 6
Source File: UrlUtils.java From govpay with GNU General Public License v3.0 | 5 votes |
public static URL addParameter(URL url, String paramName, String paramValue) throws MalformedURLException { String urlString = url.toString(); if(urlString.contains("?")) { if(urlString.endsWith("&")) urlString = urlString + paramName + "=" + paramValue; else urlString = urlString + "&" + paramName + "=" + paramValue; } else { urlString = urlString + "?" + paramName + "=" + paramValue; } return new URL(urlString); }
Example 7
Source File: SunToolkit.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static Image getImageFromHash(Toolkit tk, URL url) { checkPermissions(url); synchronized (urlImgCache) { String key = url.toString(); Image img = (Image)urlImgCache.get(key); if (img == null) { try { img = tk.createImage(new URLImageSource(url)); urlImgCache.put(key, img); } catch (Exception e) { } } return img; } }
Example 8
Source File: RestfulGet.java From disconf with Apache License 2.0 | 5 votes |
public RestfulGet(Class<T> clazz, URL url) { HttpGet request = new HttpGet(url.toString()); request.addHeader("content-type", "application/json"); this.request = request; this.httpResponseCallbackHandler = new HttpResponseCallbackHandlerJsonHandler<T>(clazz); }
Example 9
Source File: HtmlFolder.java From olca-app with Mozilla Public License 2.0 | 5 votes |
public static String getUrl(Bundle bundle, String page) { File file = getFile(bundle, page); if (file == null) return null; try { URL url = file.toURI().toURL(); return url.toString(); } catch (Exception e) { log.error("failed to get URL for page " + bundle + "/" + page, e); return null; } }
Example 10
Source File: ContentEngines.java From flowable-engine with Apache License 2.0 | 5 votes |
protected static void initContentEngineFromSpringResource(URL resource) { try { Class<?> springConfigurationHelperClass = ReflectUtil.loadClass("org.flowable.content.spring.SpringContentConfigurationHelper"); Method method = springConfigurationHelperClass.getDeclaredMethod("buildContentEngine", new Class<?>[] { URL.class }); ContentEngine contentEngine = (ContentEngine) method.invoke(null, new Object[] { resource }); String contentEngineName = contentEngine.getName(); EngineInfo contentEngineInfo = new EngineInfo(contentEngineName, resource.toString(), null); contentEngineInfosByName.put(contentEngineName, contentEngineInfo); contentEngineInfosByResourceUrl.put(resource.toString(), contentEngineInfo); } catch (Exception e) { throw new FlowableException("couldn't initialize content engine from spring configuration resource " + resource + ": " + e.getMessage(), e); } }
Example 11
Source File: SelectRootsPanel.java From netbeans with Apache License 2.0 | 5 votes |
@NonNull private static String getDisplayName(@NonNull final URL root) { final File f = FileUtil.archiveOrDirForURL(root); return f == null ? root.toString() : f.isFile() ? f.getName() : f.getAbsolutePath(); }
Example 12
Source File: DDProvider.java From netbeans with Apache License 2.0 | 5 votes |
public InputSource resolveEntity(String publicId, String systemId) { // return a proper input source String resource; if ("http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd".equals(systemId)) { resource = "/org/netbeans/modules/j2ee/dd/impl/resources/ejb-jar_2_1.xsd"; //NOI18N } else if ("http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd".equals(systemId)) { resource = "/org/netbeans/modules/j2ee/dd/impl/resources/ejb-jar_3_0.xsd"; //NOI18N } else { return null; } URL url = this.getClass().getResource(resource); return new InputSource(url.toString()); }
Example 13
Source File: AgreementGeneratorTest.java From SeaCloudsPlatform with Apache License 2.0 | 5 votes |
@Test public void testGenerateGetAgreement() throws Exception { server.enqueue(new MockResponse(). setBody(readFile("/eu/seaclouds/planner/core/application/agreements/sla-create-agreement-response.xml"))); server.start(); URL url = server.url("/").url(); AgreementGenerator generator = new AgreementGenerator(url.toString()); String result = generator.getAgreement("templateId"); assertNotNull(result); }
Example 14
Source File: URLUtil.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static Permission getConnectPermission(URL url) throws IOException { String urlStringLowerCase = url.toString().toLowerCase(); if (urlStringLowerCase.startsWith("http:") || urlStringLowerCase.startsWith("https:")) { return getURLConnectPermission(url); } else if (urlStringLowerCase.startsWith("jar:http:") || urlStringLowerCase.startsWith("jar:https:")) { String urlString = url.toString(); int bangPos = urlString.indexOf("!/"); urlString = urlString.substring(4, bangPos > -1 ? bangPos : urlString.length()); URL u = new URL(urlString); return getURLConnectPermission(u); // If protocol is HTTP or HTTPS than use URLPermission object } else { return url.openConnection().getPermission(); } }
Example 15
Source File: MetadataCommandTest.java From sis with Apache License 2.0 | 5 votes |
/** * Tests with the same file than {@link #testNetCDF()}, but producing a XML output. * * @throws Exception if an error occurred while creating the command. */ @Test @Ignore("Requires GeoAPI 3.1") @DependsOnMethod("testNetCDF") public void testFormatXML() throws Exception { final URL url = new URL("Cube2D_geographic_packed.nc") ; // TestData.NETCDF_2D_GEOGRAPHIC.location(); final MetadataCommand test = new MetadataCommand(0, CommandRunner.TEST, url.toString(), "--format", "XML"); test.run(); verifyNetCDF("<?xml", test.outputBuffer.toString()); }
Example 16
Source File: Test.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private Test(URL base, String spec) { testCount++; try { url = new URL(base, spec); } catch (Exception x) { exc = x; } if (url != null) input = url.toString(); originalURL = url; }
Example 17
Source File: Handler.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override protected URLConnection openConnection(URL url) throws IOException { String s = url.toString(); int index = s.indexOf("!/"); if (index == -1) throw new MalformedURLException("no !/ found in url spec:" + s); throw new IOException("Can't connect to jmod URL"); }
Example 18
Source File: HttpServer.java From incubator-tajo with Apache License 2.0 | 5 votes |
protected String getWebAppsPath(String name) throws FileNotFoundException { URL url = getClass().getClassLoader().getResource("webapps/" + name); if (url == null) { throw new FileNotFoundException("webapps/" + name + " not found in CLASSPATH"); } String urlString = url.toString(); return urlString.substring(0, urlString.lastIndexOf('/')); }
Example 19
Source File: Request.java From HypFacebook with BSD 2-Clause "Simplified" License | 5 votes |
Request(Session session, URL overriddenURL) { this.session = session; this.overriddenURL = overriddenURL.toString(); setHttpMethod(HttpMethod.GET); this.parameters = new Bundle(); }
Example 20
Source File: ResourceLocator.java From Strata with Apache License 2.0 | 2 votes |
/** * Creates a resource from a {@code URL}. * * @param url the URL to wrap * @return the resource locator */ public static ResourceLocator ofClasspathUrl(URL url) { ArgChecker.notNull(url, "url"); String locator = CLASSPATH_URL_PREFIX + url.toString(); return new ResourceLocator(locator, UriByteSource.of(url)); }