wood burning stoves 2.0*
The moose likes Java in General and the fly likes Read from html file, get a copy of the html text and modify img tags src Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Read from html file, get a copy of the html text and modify img tags src" Watch "Read from html file, get a copy of the html text and modify img tags src" New topic
Author

Read from html file, get a copy of the html text and modify img tags src

cle tan
Ranch Hand

Joined: Jun 11, 2012
Posts: 68
Main reason is that I want to send these html and its images attached via javamail. I can send the html file but I need to grab hold of the images to attach


The images can vary up to 3, I have considered using HTMLReader for example : http://www.coderanch.com/t/385274/java/java/Scanning-HTML-page-HREF-IMG

and http://jtoee.blogspot.sg/2007/11/parsing-html-with-htmleditorkitparserca.html

to read the content, and I am considering to get a copy(not modify the actual html file)

instead of

I will like to get a copy of the htmlcontent, replace the first image img src='xxx' with image src='cid:image1',second image image src='cid:image2' and so on.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2247
    
    7

If your goal is to get the img tags, it doesn't matter if you get a copy first or reading directly. At the end you still need to parse or read the file. And once you do get the image tag, save it in some collection for your javamail program or email message.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
 
Consider Paul's rocket mass heater.
 
subject: Read from html file, get a copy of the html text and modify img tags src
 
Similar Threads
File path in Tomcat
Servlet returns snippet but image does not appear when run on cell phone
Struts and dynamic image sources.
Giving a URL for File
Writing to file and dynamic image pages.