I'm building an android application where I have to read a big chunk of information from a server.
The server sends the information as a JSONArray and everything is fine on the server side.
However the problem comes when I'm trying to receive this JSONArray as it seems to be too large for me to receive?
I connect to the server using HttpClient like this:
HttpParams httpParams = new BasicHttpParams();
int timeoutConnection = 20000;
HttpConnectionParams.setConnectionTimeout(httpParams, timeoutConnection);
int timeoutSocket = 20000;
HttpConnectionParams.setSoTimeout(httpParams, timeoutSocket);
HttpClient client = new DefaultHttpClient(httpParams);
HttpGet request = new HttpGet();
request.setURI(url);
HttpResponse response = null;
try {
response = client.execute(request);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
BufferedReader in = null;
if (response != null) {
in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()), 100000);
}
return in;
And I simply try to read what's in the BufferedReader with the readLine() method, however what I get back is not the full content of the response. I know this because I tried accessing the same content with a web browser and it returns the full content.
The response from the server is on a single line (might affect it, I don't know)
I'm able to read 4kb and I need to read a whopping 141kb (so I'm far off)..
My personal guess is that somewhere in my code there is a size limit.
Extra I read from the BufferedReader like this:
BufferedReader in = getResponse(new URI(params[0]));
// Read from the received buffer
String s;
StringBuilder sb = new StringBuilder(10000);
if(in != null){
while ((s = in.readLine()) != null){
sb.append(s);
}
}
Log.d("Problem: ", sb.toString());
EDIT: The response does not differ, it's always the same length
EDIT2: It seems that it was Log.d() that had a limit in print length! There was no problem to begin with... sorry!