我想捕獲一個頁面的文本,然後在我的應用程序中顯示它。 但是當我運行該程序不顯示文本。 該網站是http://www.bovalpo.com/cgi-local/xml_bcv.pl?URL=1如何顯示網站上的文字?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_examplebackground);
try {
URL url = new URL("http://www.bovalpo.com/cgi-local/xml_bcv.pl?URL=1");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String inputLine="";
String inputText = "";
while ((inputLine = in.readLine()) != null) {
inputText = inputText + inputLine;
}
System.out.println(inputText);
}catch(MalformedURLException t){
System.out.println("error de url");
} catch(Throwable t){
System.out.println("error de bufffer");
}
}
或http://stackoverflow.com/questions/2423498/how-to-get-the-html-source-of-a-page閱讀文本-from-a-html-link-in-android – kcoppock 2012-07-11 16:13:01
你有沒有收到任何錯誤信息? – ThN 2012-07-11 16:13:29
任何錯誤,我有互聯網許可證和所有! :/ – 2012-07-11 16:14:51