I want to execute curl command from java code. I have already seen couple of documents, stackoverflow questions regarding the same. But it is not giving the desired result, I am trying to run this curl command :
curl --noproxy <ip>
-i
-d "INSERT IN GRAPH <http://graph.com>{ <prop/Advanced_Data_Types> rdf:type owl:NamedIndividual ,
<http://abcd/Video> ,
<http://abcd/LearningResource/BookChapter> ;
<http://abcd/hasAuthor> <prop/Eric_Grimson> ;
<http://abcd/inLanguage> <http://abcd/#Hindi> ;
<http://abcd/sourceOrganization> <prop/IIT_Hyderabad> .}"
-u "demo:demo"
-H "Content-Type: application/sparql-query" http://<ip>:<port>/DAV/home/dba/xx
And the JAVA code :
ProcessBuilder pb = new ProcessBuilder(
"curl",
"-i",
"-d \"INSERT IN GRAPH <http://graph.com>{ <prop/Advanced_Data_Types> rdf:type owl:NamedIndividual ,<http://abcd/Video> ,<http://abcd/LearningResource/BookChapter> ;<http://abcd/hasAuthor> <prop/Eric_Grimson> ;<http://abcd/inLanguage> <http://abcd/#Hindi> ;<http://abcd/sourceOrganization> <prop/IIT_Hyderabad> .} ",
"-u \"demo:demo\"",
"-H \"Content-Type: application/sparql-query\"",
"http://<ip>:<port>/DAV/home/dba/xx");
pb.redirectErrorStream(true);
Process p = pb.start();
InputStream is = p.getInputStream();
String line;
BufferedInputStream bis = new BufferedInputStream(is);
System.out.println(bis);
Is anything wrong in my code? I want to use this particular curl command. Please help.