HttpURLConnection conn = null;
int totalSize = 0;
conn = (HttpURLConnection) new URL(url).openConnection();
conn.setConnectTimeout(10 * 1000);
conn.setRequestMethod("GET");
conn.connect();
totalSize = conn.getContentLength();
[1]:http://219.238.10.102/videos/v0/20140303/43/4c/69/cd1e834831bfafcdef321e0037050f45.mp4?key=9070001543d27aea&path=/data1/www&m=DC96181615C9D859EB81DA194598DF31A8A3F8DBD9CC94AB612C1489A6574E08E898F5CE76C1BA00DEEE348748C27D82DCCEF4183D058C45DD96616D9D87753F263ADF611C41D0531BA1BDCFD7DE9B16&uuid=4cc6f4b2f1d7b13fa4fd9b4233e0094fc016327ac6ddc126dc54d6f359bcca4b
网址是[视频的网址] [1] 我把网址放在http://web-sniffer.net/上,显示的是正确长度,即71917427。
答案 0 :(得分:0)
最后通过添加userAgent解决了这个问题:
conn.setRequestProperty("User-agent", "");