...
发生了一件奇怪的事。我无法显示结果,长度为-1。但是当我使用其他网址时。例如,pipe the output。有用。有什么想法吗?
答案 0 :(得分:1)
你能这样试试吗?地址应设置为您要阅读的网站
URL page = new URL(address);
StringBuffer text = new StringBuffer();
HttpURLConnection conn = (HttpURLConnection) page.openConnection();
conn.connect();
InputStreamReader in = new InputStreamReader((InputStream) conn.getContent());
BufferedReader buff = new BufferedReader(in);
box.setText("Getting data ...");
String line;
do {
line = buff.readLine();
text.append(line + "\n");
} while (line != null);
final String result = new String(text.toString());