私はこのコードを持っており、ダウンロードしたデータの量を教えてくれ(そしてすぐにプログレスバーに入れて)、Saxパーサーで結果を解析できるようになることを望んでいます。基本的に//xr.parse(newInputSource(request.getInputStream()));より上のすべてをコメントアウトするとします。xr.parseの行を入れ替えて、正常に動作します。しかし、現時点では、私のSaxパーサーは私に何も持っていないと言っています。それは何かと関係がありますか。(バッファ)セクションを読み取りますか?
また、メモとして、リクエストはさまざまな署名を持つHttpURLConnectionです。
/*Input stream to read from our connection*/
InputStream is = request.getInputStream();
/*we make a 2 Kb buffer to accelerate the download, instead of reading the file a byte at once*/
byte [ ] buffer = new byte [ 2048 ] ;
/*How many bytes do we have already downloaded*/
int totBytes,bytes,sumBytes = 0;
totBytes = request.getContentLength () ;
while ( true ) {
/*How many bytes we got*/
bytes = is.read (buffer);
/*If no more byte, we're done with the download*/
if ( bytes <= 0 ) break;
sumBytes+= bytes;
Log.v("XML", sumBytes + " of " + totBytes + " " + ( ( float ) sumBytes/ ( float ) totBytes ) *100 + "% done" );
}
/* Parse the xml-data from our URL. */
// OLD, and works if comment all the above
//xr.parse(new InputSource(request.getInputStream()));
xr.parse(new InputSource(is))
/* Parsing has finished. */;
誰か助けてもらえますか?
敬具、
アンディ