aspose file tools*
The moose likes Java in General and the fly likes Reading HTML using JAVA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Reading HTML using JAVA" Watch "Reading HTML using JAVA" New topic
Author

Reading HTML using JAVA

Abhijit Das
Ranch Hand

Joined: Sep 25, 2007
Posts: 156
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



Abhijit Das
SCJP 5.0 | SCWCD 1.5
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
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

Joined: Sep 25, 2007
Posts: 156
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Mar 22, 2000
Posts: 12769
    
    5
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

Joined: Oct 29, 2001
Posts: 8867
    
    8

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Abhijit Das
Ranch Hand

Joined: Sep 25, 2007
Posts: 156
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
Marshal

Joined: Mar 22, 2005
Posts: 41529
    
  53
The (J)TextArea class can't do that. Have a look at the JEditorPane class Joe linked to.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading HTML using JAVA