简体   繁体   中英

What is the java equivalent of the curl command?

Can anyone help me to convert the following into java equivalent?

curl -XGET 'localhost:9200/indexname/status/_search?pretty=1&size=10000' -d '{"_source": {"include": [ "ID", "Name" ]}}'

I tried to use this:

ProcessBuilder pb = new ProcessBuilder("curl","-g","-H Content-Type: application/json", "-H Accept: application/json", "-XGET","http://localhost:9200/indexname/status/_search?pretty=1&size=10000","-d '{\"_source\": {\"include\": [ \"ID\", \"Name\" ]}}'");

On running the java code, it return a Parse failure exception. Any advice? Thanks.

I found this which works for me.

https://github.com/eeichinger/jcurl

jCurl is a curl-inspired, java-based HTTP command line client. It can be distributed as a single executable JAR

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM