サイトに投稿するアプリを開発しており、エンティティの応答を文字列として保存しようとしています。ただし、文字列には応答のごく一部 (約 35 行程度) しか含まれていないようです。バッファオーバーフローと関係があるのか 疑問に思っていますが、実際にはわかりません。私のコードは以下の通りです:
static String getResponseBody(HttpResponse response) throws IllegalStateException, IOException{
String content = null;
HttpEntity entity = response.getEntity();
if (entity != null)
{
InputStream is = entity.getContent();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = br.readLine()) != null)
{
if(isBlankString(line) == false)
{
sb.append(line + "\n");
}
}
br.close();
content = sb.toString();
}
return content;
isBlankString は、私を悩ませていた応答に空白行がたくさんあるため、行に文字が含まれていないかどうかだけを示します。これの有無にかかわらず、応答全体が得られないという問題があります。何が起こっているのか、またはこれを修正する方法を知っている人はいますか?
ありがとう