// 通过url获取数据 public static String Getpath(String path) { StringBuffer buffer = new StringBuffer(); URL url; try { url = new URL(path); HttpURLConnection connection = (HttpURLConnection) url .openConnection(); InputStream stream = connection.getInputStream(); byte[] by = new byte[1024]; int len = 0; while ((len = stream.read(by)) != -1) { buffer.append(new String(by, 0, len, "UTF-8")); } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } Log.e("TAG", buffer.toString()); return buffer.toString(); }
log里面打印结果有乱码出现了,求指点
解决方案
10
可能不是urf-8 的格式
90
String str = new String(buffer.toString().getBytes(“iso8859-1″),”UTF-8”);