try {
URL url = new URL("http://love.taobao.com/ajax/activity/get_activity.do?id=1");
java.net.URLConnection conn = url.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
InputStream inputStream = conn.getInputStream();
InputStreamReader isReader = new InputStreamReader(inputStream, "GBK"); // 返回的编码格式
BufferedReader bfReader = new BufferedReader(isReader);
StringBuilder sb = new StringBuilder();
for (String tmp=null; (tmp=bfReader.readLine())!=null; ) {
sb.append(tmp);
}
tv.setText(sb);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (Throwable e) {
e.printStackTrace();
}
Some Code:
InetAddress inetAddress = InetAddress.getByName("love.taobao.com");