Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Upload an HTML file along with images contained in that page

 
Muhammed Akhtar Hossain
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi/
I would like to copy an html file to a particular destination and also all the images contained in that file. Can u please help me how can I find the image names(paths) from the html page in run time ?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats going to be a bit of programming, but basically you will have to find the IMG or img tags, extract the SRC or src attribute and figure out what that means in terms of a URL. Keeping in mind that an image source might be an absolute or a relative URL - also that there may be a BASE tag in the page that specifies a base different from the one the page lives at.
Once you figure out the real URL you can open a URLConnection, get an InputStream, and read the binary image data.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic