Question: Question: Write a method called stripHtmlTags that accepts a Scanner representing an input file containing an HTML web page as its parameter, then reads that
Question: Write a method called stripHtmlTags that accepts a Scanner representing an input file containing an HTML web page as its parameter, then reads that file and prints the file's text with all HTML tags removed. A tag is any text between the characters . For example, consider the following text:
There are many pictures of my cat here, as well as my very cool blog page, which contains awesome stuff about my trip to Vegas.
Here's my cat now:
If the file contained these lines, your program should output the following text:
My web page
There are many pictures of my cat here, as well as my very cool blog page, which contains awesome stuff about my trip to Vegas.
Here's my cat now:
You may assume that the file is a well-formed HTML document and that are no characters inside tags.
instruction:
This problem will require you to process lines from the file. You must continue until all lines have been read from the file. Use the Scanner class methods hasNextLine() and nextLine() to extract the lines as String objects. You can then use class String methods to search the line for the HTML tag pair characters . I suggest you consider methods length(), indexOf(char), and substring(int,int) in a while loop to process each line extracted from the file. You will need to accommodate lines with multiple tags, including lines with only tags. For each line processed, output a line, even if there are only tag(s) on the line, in that case, the line is a blank line. Refer to the attached sample files with the converted results as a guide. The input files must be located in the directory C:\CS210DataFiles. Be aware, for String objects, the value returned by the non-static String method length() is the index of the last character in the String object. Finally, you are not to utilize the String class method replaceAll() in your solution.
You must define a method to process the input file.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
