我只需要从httpsresponse中解脱密码反应,而回答只是一纸空文:
HttpPost httppost = new HttpPost(tileURLString);
nameValuePairs.add(new BasicNameValuePair("x", String.valueOf(ValueX)));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
如果我得到回应,
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
if (entity == null) {
Log.i("Error","No content download");
}
InputStream in = entity.getContent();
这是行之有效的。 但这需要通过使用xor使这一产出被加密,因此:
String responseText = EntityUtils.toString(response.getEntity());
InputStream in = new ByteArrayInputStream(responseText.getBytes());
PS. this still not decrypt just normal inputstream but didn t work. I googled for a day. Help me please. if this work i ll go to next step (decrypt). Thanks in advance.
EDIT: or i use this method Convert InputStream to string by
private String convertStreamToString(InputStream is) {
BufferedReader reader = new BufferedReader(
new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append((line + "
"));
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return sb.toString();
}
然后,即利用这一方法将反馈到投入流,但也做了一些工作。
public InputStream convertStringToStream(String text)
throws UnsupportedEncodingException {
return new ByteArrayInputStream(text.getBytes("UTF-8"));
}