java.net.URL#toString ( )源码实例Demo

下面列出了java.net.URL#toString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: wecube-platform   文件: RealS3Client.java
@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();
}
 
源代码2 项目: JFoenix   文件: SVGGlyphLoader.java
/**
 * 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);
}
 
源代码3 项目: ache   文件: LinkFilter.java
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;
    }
 
@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;
}
 
源代码5 项目: groovy   文件: JsonSlurper.java
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);
        }
    }
}
 
源代码6 项目: netbeans   文件: SelectRootsPanel.java
@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();
}
 
源代码7 项目: HypFacebook   文件: Request.java
Request(Session session, URL overriddenURL) {
    this.session = session;
    this.overriddenURL = overriddenURL.toString();

    setHttpMethod(HttpMethod.GET);

    this.parameters = new Bundle();
}
 
源代码8 项目: incubator-tajo   文件: HttpServer.java
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('/'));
}
 
源代码9 项目: openjdk-jdk9   文件: Handler.java
@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");
}
 
源代码10 项目: openjdk-8-source   文件: Test.java
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;
}
 
源代码11 项目: sis   文件: MetadataCommandTest.java
/**
 * 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());
}
 
源代码12 项目: openjdk-jdk8u   文件: URLUtil.java
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();
    }
}
 
源代码13 项目: SeaCloudsPlatform   文件: AgreementGeneratorTest.java
@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);
}
 
源代码14 项目: netbeans   文件: DDProvider.java
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());
}
 
源代码15 项目: govpay   文件: UrlUtils.java
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);
}
 
源代码16 项目: flowable-engine   文件: ContentEngines.java
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);
    }
}
 
源代码17 项目: olca-app   文件: HtmlFolder.java
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;
	}
}
 
源代码18 项目: disconf   文件: RestfulGet.java
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);
    }
 
源代码19 项目: openjdk-jdk8u-backup   文件: SunToolkit.java
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;
    }
}
 
源代码20 项目: Strata   文件: ResourceLocator.java
/**
 * 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));
}