http获取文件大小

URL url = new URL(downloadUrl);
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  conn.setConnectTimeout(5 * 1000);
  conn.setRequestProperty("Accept-Language", Params.ACCEPT_LANGUAGE);
  conn.setRequestProperty("Charset", Params.ChARSET);
  conn.setRequestMethod("GET");
  conn.setRequestProperty("Connetion", "Keep-Alive");
  // 文件大小
  int fileSize = conn.getContentLength();

猜你喜欢

转载自deep-fish.iteye.com/blog/1682759
今日推荐