Got it figured this does the job nicely
package com.pjksolutions.jasonrpc;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class HTTPUtils
{
String Server;
String Request;
URL url;
HttpURLConnection conn;
public HTTPUtils()
{
}
public HTTPUtils(String Server)
{
this();
this.Server = Server;
}
private void InitServer()
{
try
{
this.url = new URL(this.Server);
this.conn = (HttpURLConnection) this.url.openConnection();
this.conn.setConnectTimeout(10000);
this.conn.setReadTimeout(10000);
this.conn.setRequestMethod("POST");
this.conn.setDoOutput(true);
this.conn.setDoInput(true);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
public String PostRequest(String Request)
{
this.Request = Request;
try
{
this.InitServer();
DataOutputStream wr = new DataOutputStream(
this.conn.getOutputStream());
wr.writeBytes(this.Request);
wr.flush();
wr.close();
InputStream is = conn.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
StringBuffer response = new StringBuffer();
while ((line = rd.readLine()) != null)
{
response.append(line);
response.append('\r');
}
rd.close();
return response.toString();
}
catch (Exception e)
{
return "error";
}
}
}