Need help writing this java code, it has three objectives: to process strings to compare, search, sort, and verify location of specific pattern to output result via interface Description Write a Java program to read a text file (command line input for file name), process the text file and perform the following. Print the total number of words in the file. (When using java_test.txt, I calculate the number of words, including number, as 254.) Print the total number of different words (case sensitive, meaning “We” and “we” are two different words) in the file. (When using java_test.txt, I calculate the number of different words, including number, as 168.) Print all words in ascending order (based on the ASCII code) without duplication. Write a pattern match method to find the location(s) of a specific word. This method should return all line number(s) and location(s) of the word(s) found in the file. Print all line(s) with line number(s) where the word is found by invoking the method of 4). Under each output line indicate the location(s) of the first character of the matched word (refer to the output example below). Empty lines are lines, they also have their own unique line numbers. Repeat the pattern match (4 and 5 above) until user types in EINPUT.   Important Note: Must construct searching and sorting methods and use them to perform sorting and searching. Do not use built-in methods as Collection.sort or classes such as ArrayList. Can use Built-in String methods such as equals, compareTo, indexOf, split, or others found useful. Construct a method to extract tokens (words) from either character arrays or strings. Also can construct a Class using an array of strings or array of character arrays (char array) to store the original text from the input the file

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Need help writing this java code, it has three objectives:

  1. to process strings
  2. to compare, search, sort, and verify location of specific pattern
  3. to output result via interface

Description

Write a Java program to read a text file (command line input for file name), process the text file and perform the following.

  • Print the total number of words in the file. (When using java_test.txt, I calculate the number of words, including number, as 254.)
  • Print the total number of different words (case sensitive, meaning “We” and “we” are two different words) in the file. (When using java_test.txt, I calculate the number of different words, including number, as 168.)
  • Print all words in ascending order (based on the ASCII code) without duplication.
  • Write a pattern match method to find the location(s) of a specific word. This method should return all line number(s) and location(s) of the word(s) found in the file.
  • Print all line(s) with line number(s) where the word is found by invoking the method of 4). Under each output line indicate the location(s) of the first character of the matched word (refer to the output example below).
  • Empty lines are lines, they also have their own unique line numbers.
  • Repeat the pattern match (4 and 5 above) until user types in EINPUT.

 

Important Note:

  • Must construct searching and sorting methods and use them to perform sorting and searching. Do not use built-in methods as Collection.sort or classes such as ArrayList. Can use Built-in String methods such as equals, compareTo, indexOf, split, or others found useful.
  • Construct a method to extract tokens (words) from either character arrays or strings.
  • Also can construct a Class using an array of strings or array of character arrays (char array) to store the original text from the input the file

 

A word is defined by any combination of alpha (upper or lower case) and numerical characters, all other characters are delimiters.

 

Input

The name of the text file should be read in from the Command line arguments.

 

Output   (Example of execution of your program)

 

java Project mytext.txt

The total number of word in the file is: 501

The total number of different words in the file is: 465

Words of the input file in ascending order without duplication:

// here are output of all words in ascending order without duplication

// (the content of this portion is subject to the input text file)

Please enter a word to be searched: system <Enter>

Line number 10

complete your computation a 64 bit processor system running Linux Operating System is

                

Line number 487

entire system should be based on a complete software system infrastructure design.

Please enter a word to be searched: California <Enter>

The word Caliornia is not found in the text file.

Please enter a word to be searched: EINPUT <Enter>

Bye!

 

Note: the blue color text indicates user input and <Enter> means user hit the <Enter> key

 

Specifications

This program must meet the following specifications:

  1. The name of the your source file that contain method main() must be java
  2. Name it exactly: upper/lower case letters are important!
  3. The output must match the example shown above, including white space and capitalization.
  4. Name your java program java
  5. You may not use ArrayLists. You can and should use String arrays. You must calculate in the code the size that is needed for these arrays. As in, you may not preset the array sizes using literal values in the code.

 

 

java_test.txt

James Gosling, Mike Sheridan, and Patrick Naughton initiated

the Java language project in June 1991.[23] Java was originally

designed for interactive television, but it was too advanced

for the digital cable television industry at the time.[24] The

language was initially called Oak after an oak tree that stood

outside Gosling's office. Later the project went by the name

Green and was finally renamed Java, from Java coffee, the

coffee from Indonesia.[25] Gosling designed Java with a

C/C++-style syntax that system and application programmers

would find familiar.[26]

 

Sun Microsystems released the first public implementation as

Java 1.0 in 1996.[27] It promised Write Once, Run Anywhere

(WORA) functionality, providing no-cost run-times on popular

platforms. Fairly secure and featuring configurable security,

it allowed network- and file-access restrictions. Major web

browsers soon incorporated the ability to run Java applets

within web pages, and Java quickly became popular. The Java 1.0

compiler was re-written in Java by Arthur van Hoff to comply

strictly with the Java 1.0 language specification.[28] With the

advent of Java 2 (released initially as J2SE 1.2 in December

1998 - 1999), new versions had multiple configurations built

for different types of platforms. J2EE included technologies

and APIs for enterprise applications typically run in server

environments, while J2ME featured APIs optimized for mobile

applications. The desktop version was renamed J2SE. In 2006,

for marketing purposes, Sun renamed new J2 versions as Java EE,

Java ME, and Java SE, respectively.

java_test.txt
James Gosling, Mike Sheridan, and Patrick Naughton initiated
the Java language project in June 1991.[23] Java was originally
designed for interactive television, but it was too advanced
for the digital cable television industry at the time.[24] The
language was initially called Oak after an oak tree that stood
outside Gosling's office. Later the project went by the name
Green and was finally renamed Java, from Java coffee, the
coffee from Indonesia.[25] Gosling designed Java with a
C/C++-style syntax that system and application programmers
would find familiar.[26]
Sun Microsystems released the first public implementation as
Java 1.0 in 1996.[27] It promised Write Once, Run Anywhere
(WORA) functionality, providing no-cost run-times on popular
platforms. Fairly secure and featuring configurable security,
it allowed network- and file-access restrictions. Major web
browsers soon incorporated the ability to run Java applets
within web pages, and Java quickly became popular. The Java 1.0
compiler was re-written in Java by Arthur van Hoff to comply
strictly with the Java 1.0 language specification. [28] With the
advent of Java 2 (released initially as J2SE 1.2 in December
1998
1999), new versions had multiple configurations built
for different types of platforms. J2EE included technologies
and APIS for enterprise applications typically run in server|
environments, while J2ME featured APIS optimized for mobile
applications. The desktop version was
for marketing purposes, Sun renamed new J2 versions as Java EE,
Java ME, and Java SE, respectively.
renamed J2SE. In 2006,
Transcribed Image Text:java_test.txt James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991.[23] Java was originally designed for interactive television, but it was too advanced for the digital cable television industry at the time.[24] The language was initially called Oak after an oak tree that stood outside Gosling's office. Later the project went by the name Green and was finally renamed Java, from Java coffee, the coffee from Indonesia.[25] Gosling designed Java with a C/C++-style syntax that system and application programmers would find familiar.[26] Sun Microsystems released the first public implementation as Java 1.0 in 1996.[27] It promised Write Once, Run Anywhere (WORA) functionality, providing no-cost run-times on popular platforms. Fairly secure and featuring configurable security, it allowed network- and file-access restrictions. Major web browsers soon incorporated the ability to run Java applets within web pages, and Java quickly became popular. The Java 1.0 compiler was re-written in Java by Arthur van Hoff to comply strictly with the Java 1.0 language specification. [28] With the advent of Java 2 (released initially as J2SE 1.2 in December 1998 1999), new versions had multiple configurations built for different types of platforms. J2EE included technologies and APIS for enterprise applications typically run in server| environments, while J2ME featured APIS optimized for mobile applications. The desktop version was for marketing purposes, Sun renamed new J2 versions as Java EE, Java ME, and Java SE, respectively. renamed J2SE. In 2006,
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education