Here you can find the source of getImgs(final String html)
public static List<String> getImgs(final String html) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.Reader; import java.io.StringReader; import java.util.LinkedList; import java.util.List; import javax.swing.text.MutableAttributeSet; import javax.swing.text.html.HTML.Attribute; import javax.swing.text.html.HTML.Tag; import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.parser.ParserDelegator; public class Main { public static List<String> getImgs(final String html) throws IOException { final List<String> imgs = new LinkedList<String>(); if (null == html || html.isEmpty()) { return imgs; }//from w w w . ja v a2 s . c om final Reader r = new StringReader(html); ParserDelegator pd = new ParserDelegator(); pd.parse(r, new HTMLEditorKit.ParserCallback() { public void handleSimpleTag(Tag t, MutableAttributeSet a, int pos) { if (Tag.IMG.equals(t)) { imgs.add((String) a.getAttribute(Attribute.SRC)); } } }, false); r.close(); if (imgs.size() > 0) { return imgs; } else { return null; } } }