各位大神
private static String getJson(String url){
// String url = "http://data1.cnr.cn/minzu_hanyuzhuan/phpencode.php?word="+para;
URL oldUrl;
StringBuffer buffer = null;
try {
oldUrl = new URL(url);
HttpURLConnection con = (HttpURLConnection) oldUrl.openConnection();
con.setRequestMethod("GET");
con.addRequestProperty("Content-Type",
"application/json;charset=utf-8");
con.connect();
InputStream in = con.getInputStream();
BufferedReader bf=new BufferedReader(new InputStreamReader(in,"UTF-8"));
buffer=new StringBuffer();
String line="";
while((line=bf.readLine())!=null){
buffer.append(line);
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String json = buffer.toString();
return json;
}
该方法得到的json字符串中的少数民族语言都是乱码,该怎么解决这个问题?