• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading HTML using JAVA

 
Abhijit Das
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
I want to display the HTML file in the TextArea using JAVA.
Java file will read the html contents and display it whole in the TextArea . No source code will be displayed only actual html contents.

thanks

 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you accomplished so far? Can you use Java IO methods to read a text file? At what point in the project are you stuck?

Bill
 
Abhijit Das
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can read the text file using IO . but i want to read the HTML file only. Is there any APIs to read HTML format???

Thanks
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Abhijit Das:
No source code will be displayed only actual html contents.
I don't understand this. HTML is source code, and the contents are the source code.

Did you mean you wanted to render the HTML in the same way as a browser would render it? That's much more complicated than just displaying the contents of the file.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want a toolkit that knows how to parse HTML and let you extract the various parts, look at JTidy.

Warning - this is not a simple project if you are dealing with anything beyond simple HTML pages.

Bill
 
Joe Ess
Bartender
Posts: 9318
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JEditorPane can display rendered HTML, but only for very simple pages (HTML 3.2, no CSS or JavaScript if I recall correctly).
There are more fully-featured browsers that can be embedded in your application for a price, for example, ICEBrowser.
 
Abhijit Das
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Paul Clapham ,

Yes, I want to get the formatted content which shows in browser.
example, <b>Hello</b> World...... is in sample.html
I want my TextArea in Demo.java should display like
HelloWorld
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The (J)TextArea class can't do that. Have a look at the JEditorPane class Joe linked to.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic