public class HttpPostClient
extends java.lang.Object
| Constructor and Description |
|---|
HttpPostClient() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
getResponseString(java.io.InputStream is)
Get the Response String from the InputStream
|
static java.lang.String |
getURLEncodedString(java.util.Map requestProps)
Returns a URL-encoded string of the given request properties
|
static void |
main(java.lang.String[] args)
Main method
|
static java.io.InputStream |
postBinaryData(java.lang.String uri,
byte[] data,
java.util.Map headers,
java.lang.String contentType)
Post the data given as bytes
|
static java.io.InputStream |
postTextData(java.lang.String uri,
java.lang.String data,
java.util.Map headers,
java.lang.String contentType)
Post the given text data
|
static java.io.InputStream |
postURLEncodedData(java.lang.String uri,
java.util.Map requestProps,
java.util.Map headers)
Post the given data as URL-encoded of the type
application/x-www-form-urlencoded
|
static byte[] |
readBinaryData(java.lang.String fileName)
Utility method to read binary data from a file
|
static java.lang.String |
readTextData(java.lang.String fileName,
java.lang.String charEncoding)
Utility method to read text data from a file.
|
public static java.io.InputStream postBinaryData(java.lang.String uri,
byte[] data,
java.util.Map headers,
java.lang.String contentType)
throws java.io.IOException
uri - the URLdata - the dataheaders - Map of headers which will be converted to HTTP headerscontentType - the HTTP Content-Type header. If null, then a
Content-Type of application/binary will be usedjava.io.IOExceptionpublic static java.io.InputStream postTextData(java.lang.String uri,
java.lang.String data,
java.util.Map headers,
java.lang.String contentType)
throws java.io.IOException
uri - the URLdata - the text dataheaders - Map of headers which will be converted to HTTP headerscontentType - the HTTP Content-Type header. If null, then a
Content-Type of text/xml; charset=UTF-8 will be usedjava.io.IOExceptionpublic static java.io.InputStream postURLEncodedData(java.lang.String uri,
java.util.Map requestProps,
java.util.Map headers)
throws java.lang.Exception
uri - the URI to post datarequestProps - the Map containing the request propertiesheaders - the HTTP headersjava.lang.Exceptionpublic static java.lang.String getURLEncodedString(java.util.Map requestProps)
throws java.lang.Exception
requestProps - the Map containing the request propertiesjava.lang.Exceptionpublic static java.lang.String getResponseString(java.io.InputStream is)
throws java.io.IOException
is - the Input Streamjava.io.IOException - if any IO error occurs while reading the streampublic static byte[] readBinaryData(java.lang.String fileName)
throws java.io.IOException
fileName - the absolute path to the filejava.io.IOException - if any IO error occurs while reading the filepublic static java.lang.String readTextData(java.lang.String fileName,
java.lang.String charEncoding)
throws java.io.IOException
fileName - the absolute path to the filecharEncoding - the character encoding of the filejava.io.IOException - if any IO error occurs while reading the filepublic static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception - if any error occurs