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

  The similarities osi model and the tcp/ip architecture

List and describe each layer of the OSI model. What is the main purpose of the OSI model.

  How two floating point numbers are added together

describe how two floating point numbers are added together, specifying all necessary operations on the various parts of the operands and the result.

  Developing uml sequence diagram for uploading document

For the existing Blackboard system, a system utilized for virtual classroom, grades, messages, and announcements, develop ONE UML Sequence Diagram for uploading the document to Blackboard.

  Writing down the code

Suppose that the a, b and c are char variables has been declared. Write some code which reads the first character of next line into a.

  Pros and cons of application software in business

Operating system software for your personal PC: define What are the differences among Windows OSs

  Procedure to generate indexes for foreign keys

Procedure to generate indexes for foreign keys.

  Difference between system software and application software

What is difference between system software and application software? How do you find out the operating system version that is installed on your computer.

  What is the best way for sending people out

What is the best way for sending people out if one wants the total competition to be over as early as possible? More precisely give an efficient algorithm that produces a schedule whose completion time is as small as possible.

  Describe the program development cycle

Describe the importance of using a structured, modular approach when creating program requirements, design, and code.

  Recoginizing the error in given code

Identify the problem in the above code, If ( toupper( response[ 0 ] ) == 'Y' )

  Illustrate precedence graph

Illustrate precedence graph

  How to generate a class diagram for the entity classes

How to generate a class diagram for the entity classes

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