Example usage for java.net URI create

List of usage examples for java.net URI create

Introduction

In this page you can find the example usage for java.net URI create.

Prototype

public static URI create(String str) 

Source Link

Document

Creates a URI by parsing the given string.

Usage

From source file:Main.java

public static boolean launchURL(String urlString) {
    try {//from   w  ww. j a  v  a 2 s  .  c o  m
        Desktop.getDesktop().browse(URI.create(urlString));
        return true;
    } catch (IOException e) {
        return false;
    }
}

From source file:com.appleframework.cache.jedis.misc.URIBuilder.java

public static URI create(String uri, int database, String password) {
    String[] parts = uri.split(":");
    if (parts.length - 1 >= 3) {
        String port = parts[parts.length - 1];
        uri = "[" + uri.replace(":" + port, "") + "]:" + port;
    }//ww  w  .j av  a2 s.  c o  m
    if (StringUtils.isEmpty(password)) {
        return URI.create("redis://" + uri + "/" + database);
    } else {
        return URI.create("redis://" + password + "@" + uri + "/" + database);
    }
}

From source file:com.github.tomakehurst.wiremock.common.UniqueFilenameGenerator.java

public static String generate(final Request request, final String prefix, final String id) {
    URI uri = URI.create(request.getUrl());
    return getRandomId(prefix, id, uri);
}

From source file:com.fatwire.dta.sscrawler.util.UriUtil.java

public static String extractPageName(final String uri) {
    final String qs = URI.create(uri).getRawQuery();
    if (qs != null) {
        for (final String p : qs.split("&")) {
            if (p.startsWith(UriUtil.PAGENAME_KEY)) {
                try {
                    return URLDecoder.decode(p.substring(UriUtil.PAGENAME_KEY.length()), UriUtil.UTF8);
                } catch (final UnsupportedEncodingException e) {
                    UriUtil.log.error(e, e);
                }// w  w  w .  j  av  a 2  s.c o  m
            }
        }

    }
    return null;

}

From source file:eu.esdihumboldt.hale.io.haleconnect.HaleConnectUrnBuilder.java

/**
 * Build a project URN from owner and project ID
 * /*from  w  ww. j av  a 2s.c o  m*/
 * @param owner the project owner
 * @param projectId the project ID
 * @return the hale-connect project URN
 */
public static URI buildProjectUrn(Owner owner, String projectId) {
    return URI.create(MessageFormat.format("{0}:project:{1}:{2}:{3}", SCHEME_HALECONNECT,
            owner.getType().getJsonValue(), owner.getId(), projectId));
}

From source file:at.beris.virtualfile.util.UrlUtils.java

public static URL normalizeUrl(URL url) throws IOException {
    URI uri = URI.create(url.toString());
    return uri.normalize().toURL();
}

From source file:org.apache.usergrid.utils.HttpUtils.java

public static Map<String, List<String>> parseQueryString(String queryString) {
    Map<String, List<String>> mapOfLists = new HashMap<String, List<String>>();
    if ((queryString == null) || (queryString.length() == 0)) {
        return mapOfLists;
    }/*from   w w w  .  j  a v  a2  s.c  o  m*/
    List<NameValuePair> list = URLEncodedUtils.parse(URI.create("http://localhost/?" + queryString), "UTF-8");
    for (NameValuePair pair : list) {
        List<String> values = mapOfLists.get(pair.getName());
        if (values == null) {
            values = new ArrayList<String>();
            mapOfLists.put(pair.getName(), values);
        }
        if (pair.getValue() != null) {
            values.add(pair.getValue());
        }
    }

    return mapOfLists;
}

From source file:com.google.mr4c.config.ConfigUtils.java

public static void dumpProperties(Properties props, String filePath) throws IOException {
    ContentFactories.writeContent(URI.create(filePath), props);
}

From source file:Main.java

public static DocumentBuilder createDocumentBuilder() throws ParserConfigurationException {
    DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
    builderFactory.setNamespaceAware(true);
    DocumentBuilder builder = builderFactory.newDocumentBuilder();
    builder.setEntityResolver(new EntityResolver() {
        public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            InputStream source = !systemId.startsWith("file:") ? null
                    : getClass().getResourceAsStream(
                            "/net/sf/logsupport/" + new File(URI.create(systemId)).getName());

            return source == null ? new InputSource(new StringReader("")) : new InputSource(source);
        }//  w w  w  .  j  a  v  a 2 s.  c  o  m
    });
    return builder;
}

From source file:appserver.grupo5.HttpDeleteWithBody.java

public HttpDeleteWithBody(final String uri) {
    super();
    setURI(URI.create(uri));
}