23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Code Fragment 5.12: <strong>Java</strong> program for test<strong>in</strong>g for<br />

match<strong>in</strong>g tags <strong>in</strong> an HTML document. (Cont<strong>in</strong>ued from<br />

5.11.) Method isHTMLMatched uses a stack to store<br />

the names of the open<strong>in</strong>g tags seen so far, similar to<br />

how the stack was used <strong>in</strong> Code Fragment 5.10.<br />

Method parseHTML uses a Scanner s to extract the<br />

tags from the HTML document, us<strong>in</strong>g the pattern<br />

"]*>," which denotes a str<strong>in</strong>g that starts with '',<br />

followed by a '>'.<br />

283

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!