below used my elasticsearch call api
···
===========================================
HttpURLConnection conn;
InputStream connIs;
String contentType;
String returnData;
PrintWriter pw;
String method;
String param;
String url;
URL u = new URL(url);
conn = (HttpURLConnection) u.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod(“POST”);
conn.connect();
pw = new PrintWriter(conn.getOutputStream());
pw.print(param);
pw.flush();
StringBuffer sb = new StringBuffer();
connIs = conn.getInputStream();
int l = 0;
byte b = new byte[4096];
while ( (l = connIs.read(b)) != -1 ) {
sb.append(new String(b, 0, l));
}
String returnData = sb.toString();
============================================================
addition : project do not change other library that required upper jdk(1.6)