下載網絡文件HttpURLConnection.getContentLength()大小爲 0

默認狀況下,HttpURLConnection使用gzip方式獲取,要取得長度則要求http請求不要gzip壓縮; HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("Accept-Encoding", "identity"); // 添加這行代碼 conn.conn
相關文章
相關標籤/搜索