Write a method named findHtmlTags that accepts aScanner. The Scanner parameter r
ID: 3611616 • Letter: W
Question
Write a method named findHtmlTags that accepts aScanner. The Scanner parameter represents an input file. Yourmethod should read the file, assuming that the file contains anHTML web page, and prints all the HTML tags in the file. A tag isany text between <and> characters. For example,If the file contains the followingtext:
<html>
<head>
<title>My web page</title>
</head>
<body>
<p>There are many pictures of my cat here,
as well as my <b>very cool</b> blog page,
which contains <font color="red">awesome</font>
stuff about my trip to Vegas.<p>
Here's my cat now: <img
src="https://s3.amazonaws.com/answer-board-image/cat.jpg">
</body>
</html>
Your program should output the followingtext:
<html>
<head>
<title>
</title>
</head>
<body>
<p>
<b>
</b>
<font color="red">
</font>
<p>
<imgsrc="https://s3.amazonaws.com/answer-board-image/cat.jpg">
</body>
</html>
Assume that the file is a well-formed HTMLdocument. Assume that no tag contains a < or > characterinside itself.
public static void main (String[] args)throws IOException {
Scanner infile = new Scanner(newFile("Sample.html");
findHtmlTags(infile);
infile.close();
}
Explanation / Answer
please rate - thanks import java.util.*; import java.io.*; public class untitled1 {public static void main (String[] args) throws IOException { Scanner infile = new Scanner(newFile("Sample.html")); findHtmlTags(infile); infile.close(); } public static void findHtmlTags(Scanner infile) {String input; int len,i,j; while(infile.hasNext()) { input=infile.nextLine(); len=input.length(); for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.