java - 为什么 Android Volley 响应字符串这么短

标签 java android android-volley

当我使用Android Volley从网络上提取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);
}

谁知道这个问题请告诉我!非常感谢!

最佳答案

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

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

关于java - 为什么 Android Volley 响应字符串这么短,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27888587/

相关文章:

java - 需要反序列化 json 格式的帮助

java - 为垃圾收集清除 BST 的最佳方法是什么?

android - 将数据发布到服务器提供空值

java - 在 Volley 中发出发布请求的通用函数

java - 如果实例没有分配泛型类型,则每个循环问题中的泛型

java - 当组件有 wicket :id? 时如何输出类标签

java - Android - 检查数据库中是否存在行

android - Google Maps API Android - 图 block 提供商的图 block 分辨率

android - 带有 Volley 的 Android Cardview 和 Recycler 错误

Android Volley, JsonObjectRequest 但收到 JsonArray