为什么Android Volley Response String如此之短

时间:2015-01-11 15:12:59

标签: java android android-volley

当我使用Android Volley从Web上提取Web HTML信息时,我发现响应字符串很短,我无法获得有用的信息。下面是代码:

private static void requestTest(RequestQueue mQueue) {
    StringRequest stringRequest = new StringRequest("http://www.baidu.com/",new Response.Listener<String>() {
        @Override
        public void onResponse(String s) {
            Log.v(TAG,"s length="+s.length());   **//Here i Found the length is 7619,it's too short**
            Log.v(TAG,"s="+s.toString());  /**/To Display s on the Console I found the s did not contain the all Info of the web.**
        }
    },new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {

        }
    });
    mQueue.add(stringRequest);
}

任何知道这个问题的人,请告诉我!非常感谢!

1 个答案:

答案 0 :(得分:1)

您只能在一条日志消息中记录~4k个字符。您尝试记录的长度是7k,因此它会被剔除。最简单/最快捷的解决方法是将消息拆分为多个logcat条目,例如:

for( String line : s.split("\n") ) {
    Log.d( TAG, line );
}