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:MainClass.java

public void actionPerformed(ActionEvent e) {
    try {/* w w  w. j a v a  2s .  c  om*/
        URL url = new URL(e.getActionCommand());
        view.setPage(url);
        commandLine.setText(url.toExternalForm());
    } catch (MalformedURLException e2) {
        System.out.println("Bad URL: " + e.getActionCommand());
    } catch (java.io.IOException e2) {
    }
}

From source file:net.sbbi.upnp.devices.UPNPRootDevice.java

/**
 * Parsing an URL from the descriptionXML file
 * @param url the string representation fo the URL
 * @param baseURL the base device URL, needed if the url param is relative
 * @return an URL object defining the url param
 * @throws MalformedURLException if the url param or baseURL.toExternalForm() + url
 *                               cannot be parsed to create an URL object
 *//*w w  w .  ja v  a2s.c o  m*/
public final static URL getURL(String url, URL baseURL) throws MalformedURLException {
    URL rtrVal;
    if (url == null || url.trim().length() == 0)
        return null;
    try {
        rtrVal = new URL(url);
    } catch (MalformedURLException malEx) {
        // maybe that the url is relative, we add the baseURL and reparse it
        // if relative then we take the device baser url root and add the url
        if (baseURL != null) {
            url = url.replace('\\', '/');
            if (url.charAt(0) != '/') {
                // the path is relative to the device baseURL
                String externalForm = baseURL.toExternalForm();
                if (!externalForm.endsWith("/")) {
                    externalForm += "/";
                }
                rtrVal = new URL(externalForm + url);
            } else {
                // the path is not relative
                String URLRoot = baseURL.getProtocol() + "://" + baseURL.getHost() + ":" + baseURL.getPort();
                rtrVal = new URL(URLRoot + url);
            }
        } else {
            throw malEx;
        }
    }
    return rtrVal;
}

From source file:de.kopis.glacier.commands.AbstractCommand.java

protected void setEndpoint(final URL endpoint) {
    client.setEndpoint(endpoint.toExternalForm());
    // TODO check if this really fixes #13
    sqs.setEndpoint(endpoint.toExternalForm().replaceAll("glacier", "sqs"));
    sns.setEndpoint(endpoint.toExternalForm().replaceAll("glacier", "sns"));
}

From source file:jp.dip.komusubi.botter.util.BitlyUrlUtil.java

@Override
public String shorten(URL url) {
    return shorten(url.toExternalForm());
}

From source file:edu.depaul.armada.Armada.java

public void startServer(String[] args) throws Exception {
    server = new Server(8083);

    ResourceHandler resourceHandler = new ResourceHandler();
    resourceHandler.setDirectoriesListed(true);
    resourceHandler.setWelcomeFiles(new String[] { "index.html" });

    // loads dashboard from classpath
    ClassLoader loader = Armada.class.getClassLoader();
    URL resource = loader.getResource("assets/");
    String webDir = resource.toExternalForm();

    resourceHandler.setResourceBase(webDir);

    ServletHandler servletHandler = new ServletHandler();
    DispatcherServlet dispatcherServlet = new DispatcherServlet();
    dispatcherServlet.setContextConfigLocation("classpath:/beans/armada-config.xml");
    ServletHolder servletHolder = new ServletHolder(dispatcherServlet);
    servletHandler.addServlet(servletHolder);

    WebAppContext webApp = new WebAppContext();
    webApp.setResourceBase(webDir);//from w w w. j  a va 2  s.c  o m
    webApp.setContextPath("/");
    webApp.addServlet(servletHolder, "/");

    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] { resourceHandler, webApp });
    server.setHandler(handlers);

    server.start();
    server.join();
}

From source file:fr.free.movierenamer.stream.VideoDetective.java

@Override
protected boolean isUrlSupported(URL url) {
    return urlPattern.matcher(url.toExternalForm()).find();
}

From source file:ngpanwei.backlog.web.SimplestServer.java

private WebAppContext getWebAppContext() {
    final URL warUrl = this.getClass().getClassLoader().getResource("ngpanwei");
    final String warUrlString = warUrl.toExternalForm();
    final String CONTEXTPATH = "/";
    WebAppContext context = new WebAppContext(warUrlString, CONTEXTPATH);
    context.setResourceBase(resourceBase);
    context.setDescriptor(descriptor);//  ww w .  j ava2  s . c  o  m

    context.setParentLoaderPriority(true);
    return context;
}

From source file:org.jcodec.player.filters.http.HttpMedia.java

private String requestInfo(URL url, HttpClient client) throws IOException {
    HttpGet get = new HttpGet(url.toExternalForm());
    get.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.IGNORE_COOKIES);
    HttpResponse response = privilegedExecute(client, get);
    if (response.getStatusLine().getStatusCode() == 200) {
        return EntityUtils.toString(response.getEntity());
    } else/* w w w .  j  a va 2s .com*/
        throw new IOException("Could not get the media info [" + url.toExternalForm() + "]:"
                + response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
}

From source file:de.kopis.glacier.AbstractGlacierCommand.java

protected void setEndpoint(final URL endpoint) {
    log.info("Using endpoint " + endpoint);

    client.setEndpoint(endpoint.toExternalForm());
    // TODO check if this really fixes #13
    sqs.setEndpoint(endpoint.toExternalForm().replaceAll("glacier", "sqs"));
    sns.setEndpoint(endpoint.toExternalForm().replaceAll("glacier", "sns"));
}

From source file:com.esri.geoportal.harvester.ckan.data.gov.DataGovBrokerDefinitionAdaptor.java

public void setXmlUrl(URL hostUrl) {
    this.xmlUrl = hostUrl;
    set(P_XML_URL, hostUrl.toExternalForm());
}