次のコードを使用して、サイズ 51kb の屋外 HTML コンテンツをダウンロードしています
HttpGet httpget = new HttpGet(url);
System.out.println("executing request" + httpget.getRequestLine());
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
System.out.println("----------------------------------------");
if (entity != null) {
System.out.println("Response content type: " + entity.getContentType());
long contentLength = entity.getContentLength();
System.out.println("Response content length: "+ entity.getContentLength());
if (contentLength > 0) {
b = new byte[(int) contentLength];
entity.getContent().read(b);
content=new String(b);
content=content.replace("\n", "").replace("\r", "");
//content = StringEscapeUtils.escapeHtml(content);
System.out.println("Response content: " + content);
}
}
HTML コンテンツの 30 ~ 40 % のみがダウンロードされて表示されます。完全なコンテンツを取得できません。
bのバイトサイズを大きくしてみました。しかし、私には何もうまくいきませんでした。
Java コードを使用して屋外コンテンツをダウンロードするのを手伝ってください。どんな助けでも大歓迎です。前もって感謝します。