java - Crawl the web page content but got garbled -


i used httpclient 4.3.6 googleplay web page content , write local file,but text garbled such "鈥�",here code:

//httpclient .... httpentity entity = response.getentity(); inputstream in = entity.getcontent(); byte[] b = new byte[2048]; stringbuffer out = new stringbuffer(); for(int n;(n=in.read(b))!=-1;) {     out.append(new string(b, 0, n, "utf-8")); } 

because googleplay's response headers show "content-type:text/html; charset=utf-8"

then used commons.io.ioutils

ioutils.tostring(in, "utf-8"); 

the problem can't sovled. how should do


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -