再会。刚刚从objective-c切换到java并尝试将url内容正常读取为字符串。阅读大量帖子,但仍然会产生垃圾。
public class TableMain {
/**
* @param args
*/
@SuppressWarnings("deprecation")
public static void main(String[] args) throws Exception {
URL url = null;
URLConnection urlConn = null;
try {
url = new URL("http://svo.aero/timetable/today/");
} catch (MalformedURLException err) {
err.printStackTrace();
}
try {
urlConn = url.openConnection();
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader input = new BufferedReader(new InputStreamReader(
urlConn.getInputStream(), "UTF-8"));
StringBuilder strB = new StringBuilder();
String str;
while (null != (str = input.readLine())) {
strB.append(str).append("\r\n");
System.out.println(str);
}
input.close();
} catch (IOException err) {
err.printStackTrace();
}
}
}
怎么了?我得到这样的东西
??y??'??)j1???-?q?E?|V??,??< 9??d?Bw(?э?n?v?)i?x????? Z????q?MM3~??????G??љ??l?U3"Y?]???? zxxDx????t^???5???j? ?k??u?q?j6?^t???????W??????????~?????????o6/ ?|?8??{? ??O????0?M>Z{srs??K???XV??4Z??'??n/??^??4????w+?????e? ??????[?{/??,??WO???????????.?.?x???????^?rax??]?xb?? & ??8;?????}???h????H5????v?e?0?????-?????g?vN