try {
URL u = new URL("sitename");
URLConnection conn = u.openConnection();
DataInputStream in = new DataInputStream ( conn.getInputStream ( ) ) ;
BufferedReader d = new BufferedReader(new InputStreamReader(in));
String str=null;
StringBuilder sb = new StringBuilder();
while( (str = d.readLine()) !=null)
{
sb.append(str);
}
str = sb.toString();
d.close();
WebView myWebView = (WebView) findViewById(R.id.webview);
int st=str.indexOf("block_title")-12;
int en=str.indexOf("block2")-18;
String res=str.substring(st,en);
String utf8String= new String(res.getBytes("UTF-8"), "windows-1251");;
String summary = "!"+utf8String+"";
myWebView.loadData(summary, "text/html", "utf-8");
и в WebView выходят каракули
подскажите как конвертнуть
Спасибо
InputStreamReader isr = new InputStreamReader(conn.getInputStream(), "windows-1251");
BufferedReader br = new BufferedReader(isr);
String utf8String= new String(res.getBytes("UTF-8"), "windows-1251");