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 void main(String[] args) {
    URI uri = URI.create("http://java2s.com/query.php?name=value");
    System.out.println(uri.getUserInfo());
}

From source file:Main.java

public static void main(String[] args) {
    URI uri = URI.create("http://java2s.com/query.php?name=value");
    System.out.println(uri.getQuery());
}

From source file:Main.java

public static void main(String[] args) {
    URI uri = URI.create("http://java2s.com");
    System.out.println(uri);
}

From source file:Main.java

public static void main(String[] args) {

    Path path = Paths.get(URI.create("file:///tutorial/Java/JavaFX/Topic.txt"));
    System.out.println(path);/*ww  w . ja  v  a2  s .  co m*/

    path = Paths.get(URI.create("file:///C:/tutorial/Java/JavaFX/Topic.txt"));
    System.out.println(path);

}

From source file:Test.java

public static void main(String[] args) throws Exception {
    Path newFile = FileSystems.getDefault().getPath("C:/h.html");
    URI url = URI.create("http://jdk7.java.net/");
    InputStream inputStream = url.toURL().openStream();
    Files.copy(inputStream, newFile);
    System.out.println("Site copied successfully!");

}

From source file:Test.java

public static void main(String[] args) throws Exception {
    Map<String, String> attributes = new HashMap<>();
    attributes.put("create", "true");
    URI zipFile = URI.create("jar:file:/home.zip");
    try (FileSystem zipFileSys = FileSystems.newFileSystem(zipFile, attributes);) {
        Path path = zipFileSys.getPath("docs");
        Files.createDirectory(path);
        try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(zipFileSys.getPath("/"));) {
            for (Path file : directoryStream) {
                System.out.println(file.getFileName());
            }/*w  w w  .j  a va 2 s .co  m*/
        }
    }
}

From source file:uk.co.techsols.mentis.worker.Main.java

public static void main(String args[]) {

    if (args.length != 3) {
        System.out.println(/* ww  w.  j av a  2  s.co m*/
                "Usage: type url cores\n\ttype:\n\t\tr - renderer\n\t\tt - transformer\n\turl: the url to Eiocha.\n\tcores: the number of cores to use\n\n\te.g. node.jar t http://localhost:8080/server 4\n\n");
        System.exit(1);
        return;
    }

    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("/applicationContext.xml");
    Worker worker;
    switch (args[0]) {
    case "r":
        worker = applicationContext.getBean("renderWorker", Worker.class);
        break;
    case "t":
        worker = applicationContext.getBean("transformWorker", Worker.class);
        break;
    default:
        System.out.println("Error: unreconised worker type.");
        System.exit(1);
        return;
    }

    worker.setup(URI.create(args[1]), Integer.parseInt(args[2]));
}

From source file:example.stores.StarbucksClient.java

public static void main(String[] args) {

    Traverson traverson = new Traverson(URI.create("http://localhost:8080"), MediaTypes.HAL_JSON);

    Map<String, Object> parameters = new HashMap<>();
    parameters.put("location", "40.740337,-73.995146");
    parameters.put("distance", "0.5miles");

    PagedResources<Resource<Store>> resources = traverson. //
            follow("stores", "search", "by-location").//
            withTemplateParameters(parameters).//
            toObject(TYPE_REFERENCE);//ww w  .  j  a v a2 s.  c  om

    PageMetadata metadata = resources.getMetadata();

    System.out.println(
            String.format("Got %s of %s stores: ", resources.getContent().size(), metadata.getTotalElements()));

    for (Resource<Store> resource : resources) {

        Store store = resource.getContent();

        System.out.println(String.format("- %s - %s", store.name, store.address));
    }
}

From source file:cool.pandora.modeller.GetContainerTest.java

public static void main(final String[] args) throws IOException {
    try {//w w  w  .ja va 2  s . com
        final String resource = ModellerClient.doGetContainerResources(
                URI.create("http://localhost:8080/fcrepo/rest/collection/test/001/res"));
        final Model model = ModelFactory.createDefaultModel();
        model.read(new ByteArrayInputStream(resource.getBytes()), null, "TTL");
        final ArrayList<String> children = getChilden(model);
        model.write(System.out, "TTL");
        System.out.println(children);
    } catch (ModellerClientFailedException e) {
        System.out.println(getMessage(e));
    }
}

From source file:com.jeffy.hdfs.HDFSWriteFile.java

/**
 * ??hdfs/*from w  w w .  j  a  v  a  2s  .c o  m*/
 * 
 * @param args
 */
public static void main(String[] args) {
    if (args.length < 2) {
        System.err.println("Please input two parameter!");
        System.out.println("Parameter: localfile hdfsfile");
        System.exit(1);
    }

    String localPath = args[0];
    String hdfsPath = args[1];
    //??
    Configuration config = new Configuration();
    //??
    try (InputStream in = new BufferedInputStream(new FileInputStream(localPath))) {
        FileSystem fs = FileSystem.get(URI.create(hdfsPath), config);
        try (FSDataOutputStream out = fs.create(new Path(hdfsPath), new Progressable() {
            @Override
            public void progress() {
                System.out.println(".");
            }
        })) {
            //??OutputStream,Hadooporg.apache.commons.io.IOUtils
            IOUtils.copy(in, out);
            System.out.println("File copy finished.");
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}