2011-01-14 104 views

回答

1
String tmpHtml = "<html>a whole bunch of html stuff</html>"; 
String htmlTextStr = Html.fromHtml(tmpHtml).toString(); 
2

如果你想從一個URL讀入一個字符串:

StringBuffer myString = new StringBuffer(); 
try { 
    String thisLine; 
    URL u = new URL("http://www.google.com"); 
    DataInputStream theHTML = new DataInputStream(u.openStream()); 
    while ((thisLine = theHTML.readLine()) != null) { 
     myString.append(thisLine); 
    } 
} catch (MalformedURLException e) { 

} catch (IOException e) { 

} 

// call toString() on myString to get the contents of the file your URL is 
// pointing to. 

這將給你一個普通的舊字符串,HTML標記和所有。