Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN JAVA!!! In a file called StringSearch.java, youll write a class StringSearch with a main method that uses command-line arguments as described below. The main

IN JAVA!!!

In a file called StringSearch.java, youll write a class StringSearch with a main method that uses command-line arguments as described below.

The main method should expect from 1 to 3 command-line arguments:

$ java StringSearch "" "" "" 

The overall goal of StringSearch is to take a file of text, search for lines in the file based on some criteria, then print out the matching lines after transforming them somehow.

The syntax means, as usual, that we will be describing what kinds of syntax can go in each position in more detail.

should be a path to a file. Weve included two for you to test on with examples below. It is recommended to make a few of your own files and try them out as well.

describes criteria for which lines in the file to print.

describes how to change each line in the file before printing.

Queries

The part of the command-line should be a &-separated sequence of individual queries. The individual queries are:

length= which matches lines with exactly characters

greater= which matches lines with more than characters

less= which matches lines with less than characters

contains= which matches lines containing the (case-sensitive)

starts= which matches lines starting with the

ends= which matches lines ending with the

not() which matches lines that do not match the inner query

Transforms

The part of the command-line should be a &-separated sequence of individual transforms. The individual transforms are:

upper which transforms the line to uppercase

lower which transforms the line to lowercase

first= which transforms the line by taking the first characters of the line. If there are fewer than characters, produces the whole line

last= which transforms the line by taking the last characters of the line. If there are fewer than characters, produces the whole line

replace=; which transforms the line by replacing all appearances of the first string with the second (some lines might have no replacements, and wont be transformed by this transform)

Where you see above, it should always be characters inside single quotes, like 'abc'. We chose this because it works best with command-line tools. The , , and command-line arguments should always be inside double quotes. This ensures that they wont be interpreted as commands, or parts of commands, by your terminal. Where you see above, it should always be a positive integer.

You may find the built-in Java String split method useful.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

6. The cost of the training creates a need to show that it works.

Answered: 1 week ago