I have a curl command:
curl -o map.json http://localhost:8091/pools/default/buckets/travel-sample"
How I will execute using Java. The command will give me the JSON
file, which I have to use to get some attributes from it.
I have a curl command:
curl -o map.json http://localhost:8091/pools/default/buckets/travel-sample"
How I will execute using Java. The command will give me the JSON
file, which I have to use to get some attributes from it.
You can execute your command with :
Runtime.getRuntime().exec("curl -o map.json http://localhost:8091/pools/default/buckets/travel-sample")
It is rather problematic command see this question Downloaded json should be in map.json file after executing command. You can read it using Apache Commons IO util:
FileUtils.readFileToString(new File("map.json"))
Full example is:
Process process;
try {
process = Runtime.getRuntime().exec("curl -o map.json http://localhost:8091/pools/default/buckets/travel-sample");
process.waitFor();
System.out.println(FileUtils.readFileToString(new File("map.json")));
} catch (Exception e) {
e.printStackTrace();
}