Android从 HttpResponse (或者InputStream) 获取字符串内容的代码

将写内容过程比较好的内容做个记录,下面的资料是关于Android从 HttpResponse (或者InputStream) 获取字符串内容的内容,应该对码农有些好处。
private StringBuilder inputStreamToString(InputStream is) {
String line = "";
StringBuilder total = new StringBuilder();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));

while ((line = rd.readLine()) != null) { 
    total.append(line); 
}

return total;

}

private String inputStreamToString(InputStream is) {
String s = "";
String line = "";

BufferedReader rd = new BufferedReader(new InputStreamReader(is));

while ((line = rd.readLine()) != null) { s += line; }

return s;

}

Android从 HttpResponse (或者InputStream) 获取字符串内容的代码

上一篇:python关键字、转义符和字符串格式化


下一篇:JAVA字符串格式化-String.format()的使用