java - Incomplete content (buffer) of webpage -


i want read content of webpage following methods, 60-70 percent of it.

i've tried 2 different methods read webpage, both same result. tried different urls. no errors or timeouts.

what doing wrong ?

        url url = new url(uri.tostring());     httpurlconnection urlconnection = (httpurlconnection) url.openconnection();     try     {         inputstream in = new bufferedinputstream(urlconnection.getinputstream());         bufferedreader br = new bufferedreader(new inputstreamreader(in));         stringbuilder sb = new stringbuilder();         string line = null;          while ((line = br.readline()) != null)          {             sb.append(line + "\n");         }         br.close();          this.content = sb.tostring();     }               {         urlconnection.disconnect();     } 

and

    httpget = new httpget(uri);     httpclient defaulthttp = new defaulthttpclient(httpparameters);     httpresponse response = defaulthttp.execute(get);      statusline status = response.getstatusline();     if(status.getstatuscode() == httpstatus.sc_ok)     {         httpentity entity = response.getentity();         inputstream stream = entity.getcontent();             string encoding = "utf-8";                //long length = entity.getcontentlength();         //if(entity.getcontentencoding() != null)         //{         //  encoding = entity.getcontentencoding().getvalue();         //}         //if(length > 0)         //{             byte[] buffer = new byte[1024];             long read = 0;                         {                 read = stream.read(buffer);                 if(read > 0)                 {                     this.content += new string(buffer, encoding);                 }             }while(read > 0);          //}     } 

@edit

i've tried c# , winforms. read complete html source of webpage. java-android doesn't work.

        httpwebrequest request = (httpwebrequest)httpwebrequest.create("http://www.kicker.de");         httpwebresponse response = (httpwebresponse)request.getresponse();         streamreader reader = new streamreader(response.getresponsestream());         string content = reader.readtoend();           reader.close();         response.close(); 

the httpurlconnection in apache's util jar has limited biggest bytes in response, couldn't remember number of it.

but in of time ,may use http conncetion in ui thread , it's not safe,and maybe killed, can choose deal http request in thread not ui thread. want know if in ut thread


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -