很长的字符串作为Web服务的响应 [英] very long string as a response of web service
本文介绍了很长的字符串作为Web服务的响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到一个很长的字符串作为Web服务,我收集它的响应使用的StringBuilder
,但我无法得到充分的价值我也使用的StringBuffer
,但没有成功。
I am getting a really long string as the response of the web service I am collecting it in the using the StringBuilder
but I am unable to obtain the full value I also used StringBuffer
but had no success.
下面是code我使用的:
Here is the code I am using:
private static String read(InputStream in ) throws IOException {
//StringBuilder sb = new StringBuilder(1000);
StringBuffer sb = new StringBuffer();
String s = "";
BufferedReader r = new BufferedReader(new InputStreamReader( in ), 1000);
for (String line = r.readLine(); line != null; line = r.readLine()) {
sb.append(line);
s += line;
} in .close();
System.out.println("Response from Input Stream Reader >>>" + sb.toString());
System.out.println("Response from Input S >>>>>>>>>>>>" + s);
return sb.toString();
}
任何帮助是AP preciated。
Any help is appreciated.
推荐答案
您也可以在字符串数组分割字符串才能看到所有的人
You can also split the string in array of strings in order to see all of them
String delimiter = "put a delimiter here e.g.: \n";
String[] datas=sb.toString().split(delimiter);
for(String string datas){
System.out.println("Response from Input S >>>>>>>>>>>>" + string);
}
这篇关于很长的字符串作为Web服务的响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文