サーバーに接続して応答を文字列として返す単純な関数があります。返されるデータのサイズが小さい場合でも、応答が大きい場合は正常に機能します。サーバーによって返された応答文字列を完全に保存せず、文字列を ... で終了します。驚くべきことに、system.out.println は正しい応答を返します。私を助けてください。私は本当に立ち往生しています。
protected String getResponseFromServer(String URLaddress) {
    HttpURLConnection connection = null;
    URL serverAddress = null;
    BufferedReader rd = null;
    StringBuffer sb = new StringBuffer();
    try {
        serverAddress = new URL(URLaddress);
        // set up out communications stuff
        connection = null;
        connection = (HttpURLConnection) serverAddress.openConnection();
        connection.setReadTimeout(20000);
        connection.connect();
        // read the result from the server
        rd = new BufferedReader(new InputStreamReader(
                connection.getInputStream()));
        String line;
        while ((line = rd.readLine()) != null) {
            System.out.print(line.trim());
            sb.append(line.trim());
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        // close the connection, set all objects to null
        connection.disconnect();
        connection = null;
    }
    return sb.toString();
}