Make a program find that searches all files

Assignment Help Computer Engineering
Reference no: EM1329523

Write a program Find that searches all files specified on the command line and prints out all lines containing a reserved word. For example, if you call java Find ring report.txt address.txt Homework.java, then the program might print:

report.txt: has broken up an international ring of DVD bootleggers that
address.txt: Kris Kringle, North Pole
address.txt: Homer Simpson, Springfield
Homework.java: String filename;

The reserved word is always the first command line argument.

Here is a sample program run:

java Find lamb mary1.txt mary2.txt

mary1.txt: Mary had a little lamb,
mary1.txt: little lamb, little lamb,
mary1.txt: Mary had a little lamb, its fleece was white as snow.
mary1.txt: and everywhere that Mary went, the lamb was sure to go.
mary2.txt: it made the children laugh and play to see a lamb at school.

Use the following class as your main class:

import java.io.FileNotFoundException;
import java.io.File;
import java.util.Scanner;

/**
This program searches files and prints out all lines containing
a keyword.
*/
public class Find
{
public static void main(String[] args) throws FileNotFoundException
{
if (args.length < 2)
{
System.out.println("Usage: Find keyword sourcefile1 sourcefile2 . . .");
return;
}
String keyword = args[...];
for (int i = 1; i < ...; i++)
{
String filename = args[...];
. . .
}
}
}

Reference no: EM1329523

Questions Cloud

A discrete random variable : A discrete random variable is
Explain pr function in e-business : Explain PR function in e-business and how does the PR function in an e-business organization differ from a brick-and-mortar organization
Give some examples of expenditures required : Give some examples of expenditures required on the part of small business firms to protect the environment.
Organizational managers creating healthy organizational : Describe the roles and responsibilities that organizational managers and leaders play in creating and maintaining a healthy organizational culture.
Make a program find that searches all files : Write a program Find out that searches all files specified on the command line and prints out all lines containing a reserved word.
The most common probabilistic sampling approach : The most common probabilistic sampling approach
Explain how is the aggregate supply curve : Explain how is the aggregate supply curve different from the supply curve for a single good like pizza.
Computing present value of different annuities : Find the present value of $300,000 annuity at 6% for 20 years-Find the present value of $500,000 deferred annuity at 6% for 20 (21-40) years-Find the present value of 50,000 annuity at 6% for 40 years
Presidents enforcement powers and supremacy clause : When a state law and a federal law directly conflict, application of the Supremacy clause will normally result in which law controlling?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Explain the modified scorecard approach

express the Value Based Management approach of demonstrating business value. Explain the Modified scorecard approach to measuring IT value. What is the benefit of this approach? Describe the concept of  balanced score card.

  Constraint programming

It is about the constraint programming. We have party organizations for being social. Each participant has their own preference list for parties, every party organizers has their own preference list for providing the parties.

  Technology assumption and analyzing the system

Which businesses and services would no longer be required if the perfect technology assumption were a reality for automobile? Explain how does the perfect technology assumption help with analyzing the system?

  The indicators management of the practice monitor

The Metropolitan Medical group (MMG) merged with Oak Grove Medical Group (OGMG) . The Oak Grove Medical Group has 4 offices and owns medical office building where their imaging and radiology lab and physical therapy and diagnostic laboratory center..

  What is required to maintain the data current

This question in not concerned with the effort to initially build/develop and populate a database, but at the place of the ongoing/long term effort to keep the data and DBMS current (up to date and accurate).

  The difference between roles and groups

The difference between roles and groups

  Write down a program to solve linear system

Write down a program to solve linear system

  Dtproperties and sysdiagrams

Exclude the tables “dtproperties” and “sysdiagrams”. List the column CountOfTable, in which the Table is the chosen table name.

  How many address lines are needed to access memory

How many address lines are needed to access memory.

  Improving the response to disaster

Also determine if you may find how the plans helped officials improve the response to disaster. How do the plans help the recovery?

  What are the serious challenges faced

What are the serious challenges faced when creating in-house software applications and what is the best process of training users on new software.

  Dbmss have their own language

Explain Do all DBMSs have their own language? Is it similar to a programming language.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd