We will need to use a variety of Character class and String class methods to  validate the data and separate it in order to process it. We will also use a Character class method to allow the user to continue the program if desired.  The String class’s split method will allow us to process the tokens in a text file in  order to decode a secret message. We will use the first letter of every 5th token read in  from a file to reveal the secret message.  Task #2 String.split and the StringBuilder Class  1. Copy the file secret.txt (Code Listing 9.3) from the Student Files or as directed by your instructor. This file is only one line long. It contains 2 sentences. 2. Write a main method that will read the file secret.txt, separate it into word tokens. 3. You should process the tokens by taking the first letter of every fifth word, starting with the first word in the file. Convert these letters to uppercase and append them to a StringBuilder object to form a word which will be printed to the console to display the secret message.  Code Listing 9.3 (secret.txt) January is the first month and December is the last.  Violet is a purple color as are lilac and plum.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

We will need to use a variety of Character class and String class methods to 
validate the data and separate it in order to process it. We will also use a Character
class method to allow the user to continue the program if desired. 
The String class’s split method will allow us to process the tokens in a text file in 
order to decode a secret message. We will use the first letter of every 5th token read in 
from a file to reveal the secret message. 

Task #2 String.split and the StringBuilder Class 

1. Copy the file secret.txt (Code Listing 9.3) from the Student Files or as directed by
your instructor. This file is only one line long. It contains 2 sentences.
2. Write a main method that will read the file secret.txt, separate it into word
tokens.
3. You should process the tokens by taking the first letter of every fifth word,
starting with the first word in the file. Convert these letters to uppercase and
append them to a StringBuilder object to form a word which will be printed
to the console to display the secret message. 

Code Listing 9.3 (secret.txt)
January is the first month and December is the last. 
Violet is a purple color as are lilac and plum.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,