Question: Exercise 2: Write a program that reads from a URL and searches for a given word in the URL and displays the number of times

Exercise 2: Write a program that reads from a URL and searches for a given word in the URL and displays the number of times the word appears.

Exercise 3: Write a program to create a file named numbers.txt. Create 100 random integers (you can assume some reasonable range for the integers, say, between 1 and 10000) and write them into numbers.txt. Read the data back from numbers.txt and display them in decreasing order.

*I am using JGrasp so please make sure it is compatible *Please comment throughout code *FULL QUESTION IN IMAGES BELOWExercise 2: Write a program that reads from a URL and searchesfor a given word in the URL and displays the number oftimes the word appears. Exercise 3: Write a program to create a

Exercise 0: Review the following three exercises that were discussed in the lectures. //A simple program that illustrates reading from a text file. It reads each line from the given text file and displays them on the screen import java.util. Scanner; import java.io. public class File ReadDemol public static void main (String[ args) throws IOException Scanner keyboard. Scanner System. in) new System out. print Enter the name of the file to read from String filename keyboard. nextLine File inFile new File (filename) Scanner input new Scanner (inFile); while (input.hasNext String line input. nextLine System.out.println (line) input close This program illustrates how to read from a URL /It opens the connection to the specified URL and reads each line and //displays it It also counts the total number of characters on the //webpage import java util Scanner import java.net. URL import java.io. public class ReadFileFromURL public static void main (String args) throws Exception Scanner keyboard new Scanner (System in) System. out.print Enter a URL String URLString keyboard. nextLine URL url new URL (URL string) int count Scanner input new Scanner (url openstream while input. hasNext ())f String line input. nextLine System.out.println (line); count+Jline length System. out.println ("The file size is count characters

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!