Oussaki
Oussaki

Reputation: 1649

How could a String contain all the StringBuilder result in Java

i'm writing a code that get a Json String from the google geocode api , i'm using a StringBuilder to build the String from the Input stream that i have , well the problem is when the String that the StringBuilder Have is not the same that the Function StringBuilder.tostring(); returns ...

i have a code like this :

 sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
                Log.i("line",line);
            }

this gonna show all the lines using Log.i("line",line); so well .. but when when i do :

sb.toString();

It only returns some of the String that i want ... any suggestions guys ?

Note : The Json Result of the API is so long . you can try with this one https://maps.googleapis.com/maps/api/geocode/json?address=Hospital+Jijel

Upvotes: 0

Views: 79

Answers (1)

Khantahr
Khantahr

Reputation: 8518

Writing to the log will truncate your string if it's too long, which in your case it probably is.

Write the contents of your StringBuilder to the screen or a file to see its full contents.

Upvotes: 2

Related Questions