Java Equivalent to C# Stream Write() (HttpWebRequest -> HttpURLConnection) -
public static response callservice(string strurl, string requestbody, string token, int timeout, boolean ispostmethod) { var httpwebrequest = (httpwebrequest)webrequest.create(strurl); httpwebrequest.getrequeststream().write(utf8encoding.utf8.getbytes(requestbody), 0, requestbody.length); } what equivalent of following code in java?
httpwebrequest.getrequeststream().write(utf8encoding.utf8.getbytes(requestbody), 0, requestbody.length); i'm using:
httpurlconnection urlconnection = (httpurlconnection) url.openconnection(); which java equivalent .net's httpwebrequest.
this has been addressed in few posts. there's tutorial of sorts here:
using java.net.urlconnection fire , handle http requests
that's single best source i've seen on topic provides extensive details on performing , handling http request in java.
there's question: how send http request in java?
and finally, it's based on httpurlconnection class documented here: http://docs.oracle.com/javase/7/docs/api/java/net/httpurlconnection.html
Comments
Post a Comment