android解决读取中文文件乱码的问题

2. 连接网络读取文件内容中文乱码解决办法

URL myFileUrl = null;   
   myFileUrl = new URL(url);
   HttpURLConnection conn;
   conn = (HttpURLConnection) myFileUrl.openConnection();
   conn.setDoInput(true);
   conn.connect();
   InputStream is = conn.getInputStream();
   BufferedReader br = new BufferedReader(new InputStreamReader(is,
     "GB2312"));
   sb = new StringBuffer();
   String data = "";
   while ((data = br.readLine()) != null) {   
        sb.append(data+"\n");   
   }   
   String result = sb.toString();

你可能感兴趣的:(android解决读取中文文件乱码的问题)