Example usage for java.net URI URI

List of usage examples for java.net URI URI

Introduction

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

Prototype

public URI(String str) throws URISyntaxException 

Source Link

Document

Constructs a URI by parsing the given string.

Usage

From source file:vazkii.psi.client.core.helper.SharingHelper.java

public static void uploadAndOpen(String title, String export) {
    String url = uploadImage(title, export);
    try {/*from  w  ww. j av  a 2s .com*/
        if (Desktop.isDesktopSupported())
            Desktop.getDesktop().browse(new URI(url));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.mellanox.jxio.tests.benchmarks.DataPathTest.java

protected URI generateUri() {
    String url_string = "rdma://" + server_ip + ":" + server_port;
    try {//from   w w  w . jav  a2s . com
        return new URI(url_string);
    } catch (URISyntaxException e) {
        System.out.println("Bad URI given\n");
        LOG.error("Bad URI given");
        e.printStackTrace();
    }
    return null;
}

From source file:com.cloudera.recordbreaker.analyzer.FSCrawler.java

public static void main(String argv[]) throws Exception {
    if (argv.length < 4) {
        System.err.println("Usage: FSCrawler <metadataStoreDir> <schemaDbDir> (--crawl <dir>)");
        return;//from   ww  w  .j  a  v  a  2  s . co m
    }
    int i = 0;
    File metadataStoreDir = new File(argv[i++]).getCanonicalFile();
    File schemadbdir = new File(argv[i++]).getCanonicalFile();
    String op = argv[i++];
    FSAnalyzer fsa = new FSAnalyzer(metadataStoreDir, schemadbdir);

    try {
        if ("--crawl".equals(op)) {
            File crawlTarget = new File(argv[i++]).getCanonicalFile();
            System.err.println("About to crawl " + crawlTarget);
            FSCrawler crawler = new FSCrawler(fsa);
            crawler.blockingCrawl(new URI("file://" + crawlTarget));
        } else if ("--test".equals(op)) {
            List<SchemaSummary> summaryList = fsa.getSchemaSummaries();
            System.err.println("Schema summary list has " + summaryList.size() + " entries");
        }
    } finally {
        fsa.close();
    }
}

From source file:com.cedarsoft.couchdb.io.ActionResponseSerializerTest.java

License:asdf

@DataPoint
public static Entry<? extends ActionResponse> success() throws URISyntaxException {
    return AbstractSerializerTest2.create(
            new ActionResponse(new DocId("daid"), new Revision("darev"), 200, new URI("asdf")),
            ActionResponseSerializerTest.class.getResource("ActionResponse.json"));
}

From source file:net.modelbased.proasense.storage.registry.RestRequest.java

public static String postSensor(Sensor sensor) {
    String content = JsonPrinter.sensorToJson(sensor);
    URI target = null;/*from  w  ww .ja  v a 2 s.  c o m*/
    try {
        target = new URI(sensor.getUri().toString() + SENSOR_PATH);
    } catch (URISyntaxException e1) {
        e1.printStackTrace();
    }
    HttpClient client = new DefaultHttpClient();
    HttpPost request = new HttpPost(target);
    request.setHeader("Content-type", "application/json");
    String response = null;
    try {
        StringEntity seContent = new StringEntity(content);
        seContent.setContentType("text/json");
        request.setEntity(seContent);
        response = resolveResponse(client.execute(request));
    } catch (Exception e) {
        e.printStackTrace();
    }
    return response;
}

From source file:org.grameenfoundation.consulteca.utils.HttpHelpers.java

/**
 * Convenience overload that takes a string and custom http headers.
 *///from w ww  . j  a  v  a  2  s.c o  m
public static String fetchContent(String remoteAddress, HashMap<String, String> headers) {
    try {
        return fetchContent(new URI(remoteAddress), headers);
    } catch (URISyntaxException e) {
        return null;
    }
}

From source file:com.splunk.shuttl.server.mbeans.OverrideWithOldArchiverRootURIConfiguration.java

private URI getArchiverRootURI() {
    try {/*from  w  ww  . j  av  a 2s  .c  o m*/
        return new URI(conf.getArchiverRootURI());
    } catch (URISyntaxException e) {
        throw new RuntimeException(e);
    }
}

From source file:org.sentilo.common.utils.URIUtils.java

private static URI getBaseURI(final String host, final String path) {
    try {/*from   w  w  w.j  a v  a 2 s .c o m*/
        String baseURI = null;
        if (host.endsWith(SentiloConstants.SLASH) && path.startsWith(SentiloConstants.SLASH)) {
            baseURI = host.substring(0, host.length() - 1) + path;
        } else if (!host.endsWith(SentiloConstants.SLASH) && !path.startsWith(SentiloConstants.SLASH)) {
            baseURI = host + SentiloConstants.SLASH + path;
        } else {
            baseURI = host + path;
        }

        return new URI(baseURI);
    } catch (final URISyntaxException e) {
        throw buildIllegalArgumentException(host, path, e);
    } catch (final NullPointerException npe) {
        throw buildIllegalArgumentException(host, path, npe);
    }
}

From source file:com.couchbase.sqoop.manager.CouchbaseManagerTest.java

@Before
public void setUp() {
    super.setUp();

    try {//from w  ww . ja  va  2s .  com
        URI uri = new URI(CouchbaseUtils.CONNECT_STRING);
        String user = CouchbaseUtils.COUCHBASE_USER_NAME;
        String pass = CouchbaseUtils.COUCHBASE_USER_PASS;
        cb = new CouchbaseClient(Arrays.asList(uri), user, user, pass);
    } catch (URISyntaxException e) {
        LOG.error("Bad URL" + e.getMessage());
        fail(e.toString());
    } catch (IOException e) {
        LOG.error("Couldn't connect to server" + e.getMessage());
        fail(e.toString());
    }
}