Java implements HttpGet and HttpPost requests in a variety of ways, a personal summary of the simplest way, just a few lines of code, can be perfectly implemented.
Here need to use two jar package, Httpclient-4.3.1.jar, Httpcore-4.3.jar, you can download on the Internet yourself, or to my attachment to download, the following first put on the HttpGet request code:
String uRL = "";
HttpGet request = new HttpGet (URL);
try {
HttpResponse response = Httpclients.createdefault (). Execute (Request);
if (Response.getstatusline (). Getstatuscode () ==200) {
result = Entityutils.tostring (response.getentity ());
}
}
The simple way to do this is because the jar package already encapsulates some basic things for us, with less effort.
In addition, recommend a free smart chat for the api-Turing device person. This is the experience page http://www.tuling123.com/openapi/cloud/proexp.jsp, it feels wonderful. Able to answer a variety of questions intelligently, such as "Hello-you." Your sister's--I have a few younger sister, you want which ", it is very interesting. This API is called through the HttpGet request, interested in the ability to try.
Post the code for the HttpPost request later.
Java the simplest way to implement HttpGet and HttpPost requests