in Android Code Tips

Android URLConnection ReadUTF example

URLConnection conn= null;
DataInputStream dis = null;
String url = "http://test.com/lalala.html";
StringBuffer sb1 = new StringBuffer();
try {
URL updateURL = new URL(url);
conn = updateURL.openConnection();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream(), 
"UTF8"));

String s = "";
while ((s = rd.readLine()) != null) {
sb1.append(s);
}
Log.i("AAAAA", sb1.toString());
Share