Need to do make utility to find lines in a txt that contain certain words in Java


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Need to do make utility to find lines in a txt that contain certain words in Java

Hybrid View

  1. #1
    Join Date
    Apr 2007
    Posts
    1

    Need to do make utility to find lines in a txt that contain certain words in Java

    Hi,
    I have an assignment like follows..can some one help me do this..?

    You are required to write a programme that will find lines in a text file that contain certain words. This is broadly similar to the Unix utility "grep" in concept but a number of extra facilities are required.

    The command line arguments are to be

    1. -a or -o
    A single flag of the form "-o" or "-a" specifying whether a required line will be one containing any one of the specified words ("-o" [OR] operation) or whether a required line is one containing all of the specified words ("-a" [AND] operation).
    The default is "-o" operation.

    2. -w, -t or -r
    A single flag of the form "-w", "-t" or "-r" specifying the type of word match. These are
    o word
    word matching means that the word specified on the command line must be matched exactly by a word in the line of text. This is indicated by the "-w" flag.
    o stem
    stem matching means that the word specified on the command line may be an initial substring of a word in the line of text. This is indicated by the "-t" flag.
    o string
    string matching means that the word specified on the command line is to be taken as a string of characters that occur anywhere in the line of text. This is indicated by the "-r" flag.
    For example if the word "man" appeared on the command line and stem matching were specified then words such as "mankind" and "manufacturing" would be regarded as matching, if string matching were specified then words such as "command" and "woman" would also match.
    Stem matching is the default option.

    The matching is required to be case insensitive. A word is to be taken as any sequence of alphameric characters enclosed by non-alphameric characters.

    3. File name
    The command line argument following "-f" is to be taken as the name of the file to be processed.
    This is optional. If the "-f" option does not appear on the command line then data is read from standard input.

    4. The words
    A list of one (or more) words to be found in the data file. This is not optional, the absence of any required words is an error.
    The output from the programme will be those lines of text read from the input data that satisfy the match requirements. The selected lines will be written to the standard output. You will be expected to devise a realistic set of tests for your programme and show its correct operation on a variety of data files.
    Your programme should be written in standard Java.


    Any help is appreciated


    Thanks

    Surej

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    Looks to me that you will be exercising the Scanner class and the String class and the Regex and Pattern classes. Be sure you are methodical in your plan - you'll have two different input streams; you'll have to look for whole strings or substrings at the start of a word or content within a word.

    Is your output list a list of words or lines?

Similar Threads

  1. Replies: 0
    Last Post: 09-21-2005, 12:49 AM
  2. learning c# very confusing.
    By Mike Tsakiris in forum .NET
    Replies: 11
    Last Post: 10-04-2002, 06:32 PM
  3. Replies: 0
    Last Post: 09-24-2002, 10:42 AM
  4. JAVADOTNET !!!
    By Dharmesh in forum .NET
    Replies: 4
    Last Post: 10-01-2001, 04:47 PM
  5. Will Java make things easier?
    By JayinMichigan in forum Careers
    Replies: 3
    Last Post: 06-20-2001, 03:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center