Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 BELOWimage text in transcribedimage text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

Which are non projected Teaching aids in advance learning system?

Answered: 1 week ago