views:

87

answers:

0

What is the difference between EntityTemplate and StringEntity

Below is the code from the HttpClient Tutorial. Not sure I understand why you would do this verses using a StringEntity

ContentProducer cp = new ContentProducer() { public void writeTo(OutputStream outstream) throws IOException { Writer writer = new OutputStreamWriter(outstream, "UTF-8"); writer.write(""); writer.write(" "); writer.write(" important stuff"); writer.write(" "); writer.write(""); writer.flush(); } }; HttpEntity entity = new EntityTemplate(cp); HttpPost httppost = new HttpPost("http://localhost/handler.do"); httppost.setEntity(entity);

---StringEntity HttpPost httpPost = new HttpPost(); StringEntity stringEntity = new StringEntity("important stuff"); httpPost.setEntity(stringEntity);

related questions