Function searches all files specified on the command line

Assignment Help JAVA Programming
Reference no: EM13940592

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: EM13940592

Questions Cloud

Direct labor costs were incurred : Raw materials were issued for use in production.Direct labor costs were incurred.
Analyzes and explains the facts of the williams case : Analyzes and explains the facts in the Rose case. Describes the causes of wrongful conviction in the Rose case. Analyzes and explains the facts of the Williams case.
Information systems projects get started in organizations : How do information systems projects get started in organizations? No copy and paste, use your own words. 100 word Min.
Brown company finished consultation services and accepted : On December 31, 2010 Brown Company finished consultation services and accepted in exchange a zero bearing promissory note with a face value of $400,000. Determine the present value of the note. Prepare the journal entry to record the issuance of the ..
Function searches all files specified on the command line : 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:
Contemporary ethical issue in an area of social computing : The purpose of this task is to encourage students to explore a variety of ethical theories and apply them to a contemporary ethical issue in an area of social computing.
Analyze and evaluate marx''s contribution to sociological : Analyze and evaluate Marx's contribution to sociological theory. Keep in mind that Marx's central concern was a critical analysis of capitalist society, and include the following concepts in your discussion:
Determine the punching force required : A mild steel plate of thickness 15 mm has a 50 mm diameter hole punched in it. If the ultimate shear stress of the steel is 275 MPa, determine (a) the punching force required, (b) the compressive stress in the punch.
Purchases of direct materials-beginning direct materials : For each of the following cases, find the missing data. Each case is independent of the others.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Create a package called people

Create a second package called ‘task01'. Within this package provide classes which perform the following tasks.

  Java application to declare and create a vector

Write a java application that perform the following task: declare and create a vector with initial size of 10, increment of 2

  Implement the finite field gf

Write a program called "GF2.java" to implement the finite field GF(p n )where p is a prime number andn is a positive integer.You also need to write four methodsto realize.

  Modify the numbers guessing game program

Modify the numbers guessing game program. Suppose that the variable num and guess are as declared and the diff is an int variable.

  Describing the use of java in the first intel version

Describing the use of Java in the first Intel version of the Solaris Operating system by Sun Microsystems

  Java program the program has a page that shows the users

java program the program has a page that shows the users name and program name. a second jpanel that shows 4 buttons

  Quadratic and double hashing

The methods you should use in building your has functions are linear, quadratic and double hashing. Your code should provide create, insert, ?nd and delete operations on that table.

  Creates an array of six divsales objects

Write a program that creates an array of six DivSales objects. The program should ask the user to enter the sales for four quarters for each division.

  Explain the use of file input and output in a java program

Getting input from the keyboard and sending output to the screen has limitations. If the amount of input data is large, it is inefficient to type it each time you run a program.

  Create online store web site

the Java and JSP source codes and SQL scripts for creating a database in Oracle - any configuration files used

  Purpose of alternative dispute resolution

Evaluate the purpose of Alternative Dispute Resolution (ADR) and, with particular reference to the services provided by Acas, assess to what extent it is a successful means of resolving disputes outside the formal judicial process.

  What is abstract class and how it differ from regular class

What is an abstract class and how does it differ from a regular class? Why are abstract class constructors defined as protected

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