I have a java app in which I'm just reading a file and inserting the data into the elasticsearch index.
Here is the code I 'm using.
in = new BufferedReader(new FileReader("file.txt"));
line = in.readLine();
while ((line = in.readLine()) != null) {
System.out.println("Command: curl -XPOST 'http://localhost:9200/esensor/data' -d '{ \"temp\": \""+line+"\" }'");
p = Runtime.getRuntime().exec("curl -XPOST 'http://localhost:9200/esensor/data' -d '{ \"temp\": \""+line+"\" }'");
p.waitFor();
BufferedReader err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
while ((line = err.readLine()) != null) {
System.out.println(line);
}
break;
}
in.close();
But this is not working. Curl is giving this error.
curl: (1) Protocol 'http not supported or disabled in libcurl
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (6) Could not resolve host: "temp"
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (6) Could not resolve host: "17.35757"
curl: (3) [globbing] unmatched close brace/bracket in column 1
But see I have printed the command which I'm executing. If I manually copy paste that in console then everything working fine. Why it is happening? What I'm doing wrong?