2011-01-14 43 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标记和所有。