Ok it's time for ask for help. After few hours of work I have this. I think something wrong with my trying create algorithm to solve situation when this tag is a little mess. (line 68-74).
Maybe it possible way when I could repair this program. Am I long for good solution? I feel I'm close to do this.
Read from the console the name of a file
containing HTML.
Example:
Info about Leela <span xml:lang="en"
lang="en"><b><span>Leela Turanga
</span></b></span><span>Super</span>
<span>girl</span>
The main method's first parameter is a
tag name. For example, "span".
Display all tags that match the specified
tag.
The order should match their order in the
file, each tag on a new line.
The number of spaces, newline characters
(\n), or carriage returns (\r) does not
affect the result.
The file does not have a CDATA tag. Each
opening tag has a separate closing tag,
and there are no self-closing tags.
Tags may have nested tags.
Example output:
<span xml:lang="en" lang="en"><b><span>Leela
Turanga</span></b></span>
<span>Leela Turanga</span>
<span>Super</span>
<span>girl</span>
Tag templates:
<tag>text1</tag>
<tag text2>text1</tag>
<tag
text2>text1</tag>
text1 and text2 can be empty
Requirements:
1. The program must read the file name from
the console (use BufferedReader).
2. The BufferedReader used for reading input
from the console must be closed after use.
3. The program must read the file's contents
(use FileReader).
4. The file input stream (FileReader) must
be closed.
5. The program must write to the console
all the tags that match the tag specified by
the argument passed to the main method.