返回乱码怎么处理?
风中云 2012-03-09 02:25:26 这是我的java代码
public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub
StringBuffer sb = new StringBuffer("http://www.ip168.com/mobile/?mobile=1391632");
URL url = new URL(sb.toString());
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
// connection.setRequestProperty(arg0, arg1);
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String inputline = in.readLine();
inputline=URLDecoder.decode(inputline, "utf-8");
System.out.println(inputline);
}
就这一个方法,是查询手机归属地,但是返回的结果汉字都是乱码,在别人机器上都没乱码,但是我的eclipse编码格式已经给设成utf-8了啊,怎么回事???