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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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