Example usage for java.net URL toExternalForm

List of usage examples for java.net URL toExternalForm

Introduction

In this page you can find the example usage for java.net URL toExternalForm.

Prototype

public String toExternalForm() 

Source Link

Document

Constructs a string representation of this URL .

Usage

From source file:org.cee.net.impl.HttpWebResponse.java

private String getUrlWithoutHash(URL location) {
    String result = location.toExternalForm();
    int hashIndex = result.indexOf('#');
    if (hashIndex > -1) {
        return result.substring(0, hashIndex);
    }//  w  w w.j a va  2 s.com
    return result;
}

From source file:bad.robot.http.apache.ApacheHttpClient.java

@Override
public HttpResponse delete(URL url) throws HttpException {
    return execute(new HttpDelete(url.toExternalForm()));
}

From source file:bad.robot.http.apache.ApacheHttpClient.java

@Override
public HttpResponse options(URL url) throws HttpException {
    return execute(new HttpOptions(url.toExternalForm()));
}

From source file:com.jgui.ttscrape.Bootstrap.java

public void run() {
    if (logger.isTraceEnabled()) {
        logger.trace("initializing container");
    }//w ww  . j a  v a  2  s  . com

    URL url = Bootstrap.class.getResource("/applicationContext.xml");
    ApplicationContext ctx = new FileSystemXmlApplicationContext(url.toExternalForm());
    FetchController c = ctx.getBean(FetchController.class);
    if (c != null) {
        //c.setWriteShows(true);
        //c.setWriteContent(true);
        if (c.getFetcher().init()) {
            if (readMode) {
                c.read();
            } else if (fetchMode) {
                c.fetch();
            }
        }
    } else {
        logger.error("unable to find fetch controller");
    }
}

From source file:bad.robot.http.apache.ApacheHttpClient.java

@Override
public HttpResponse put(URL url, bad.robot.http.HttpPut message) {
    HttpPut put = new HttpPut(url.toExternalForm());
    for (Header header : message.getHeaders())
        put.addHeader(header.name(), header.value());
    put.setEntity(new HttpRequestToEntity(message).asHttpEntity());
    return execute(put);
}

From source file:bad.robot.http.apache.ApacheHttpClient.java

@Override
public HttpResponse get(URL url, Headers headers) throws HttpException {
    HttpGet get = new HttpGet(url.toExternalForm());
    get.setHeaders(asApacheBasicHeader(headers));
    return execute(get);
}

From source file:demo.buttso.web.QuoteMakerTest.java

@Test
@RunAsClient/*  ww w. j a v  a 2s. c o m*/
public void checkQuoteIsPresent(@ArquillianResource URL contextPath) {
    String newContext = contextPath.toExternalForm() + "/QuoteServlet";
    LOG.info(newContext);

    InputStream in = null;

    try {
        in = new URL(newContext).openStream();
        for (String line : IOUtils.readLines(in)) {
            if (line.contains("quote")) {
                System.out.println(line);
                Assert.assertTrue("Quote found", line.contains("quote"));
                break;
            }
        }
    } catch (Exception e) {
        Assert.assertFalse("Quote not found", true);
    } finally {
        IOUtils.closeQuietly(in);
    }

}

From source file:com.esri.geoportal.harvester.agp.AgpOutputBrokerDefinitionAdaptor.java

/**
 * Sets host URL/* ww  w.  ja v a  2 s .c  om*/
 * @param url host URL
 */
public void setHostUrl(URL url) {
    this.hostUrl = url;
    set(P_HOST_URL, url.toExternalForm());
}

From source file:ch.astina.hesperid.web.services.dbmigration.impl.ClasspathMigrationResolver.java

public Set<Migration> resolve() {
    Set<Migration> migrations = new HashSet<Migration>();

    try {/*www  .ja va  2  s  . co  m*/
        Enumeration<URL> enumeration = getClass().getClassLoader().getResources(classPath);

        while (enumeration.hasMoreElements()) {

            URL url = enumeration.nextElement();

            if (url.toExternalForm().startsWith("jar:")) {
                String file = url.getFile();

                file = file.substring(0, file.indexOf("!"));
                file = file.substring(file.indexOf(":") + 1);

                InputStream is = new FileInputStream(file);

                ZipInputStream zip = new ZipInputStream(is);

                ZipEntry ze;

                while ((ze = zip.getNextEntry()) != null) {
                    if (!ze.isDirectory() && ze.getName().startsWith(classPath)
                            && ze.getName().endsWith(".sql")) {

                        Resource r = new UrlResource(getClass().getClassLoader().getResource(ze.getName()));

                        String version = versionExtractor.extractVersion(r.getFilename());
                        migrations.add(migrationFactory.create(version, r));
                    }
                }
            } else {
                File file = new File(url.getFile());

                for (String s : file.list()) {
                    Resource r = new UrlResource(getClass().getClassLoader().getResource(classPath + "/" + s));

                    String version = versionExtractor.extractVersion(r.getFilename());
                    migrations.add(migrationFactory.create(version, r));
                }
            }
        }
    } catch (Exception e) {
        logger.error("Error while resolving migrations", e);
    }

    return migrations;
}

From source file:WebstartLauncher.java

private String toURLFormat(File file) {
    try {// w  w  w.  j  a v a  2  s.  c o  m
        URL fileURL = file.toURL();
        return fileURL.toExternalForm();
    } catch (MalformedURLException ex) {
        throw new RuntimeException(ex);
    }
}