Embed presentation
Download to read offline
![In JAVA how do you encode and print each sentence in the file using a basic Caesar Cipher.
- Encode the characters by shifting their Unicode value by 5
- For example if we encoded the character 'A' with a shift of 5 it would become the character 'F'
- For example if we encoded the character 'X' with a shift of 5 it would become the character ']'
- Spaces should be printed but not encoded
- Use the method caesarCipher
Write each encoded sentence to a new text file called encoded.txt
- If a IOException is thrown catch the exception and alert the user of the error
- Use the method encodedFile
(The main method cannot be set to throw any exceptions. The text file will contain multiple lines
and each line will correspond to a single sentence.)
Sample Output:
Ex: If input is:
anexample.txt
the output is:
Please enter the name of the file:
It tw it sty1 ymjwj nx st yw~&
Qnkj nx f qtsl qjxxts ns mzrnqny~3
Ex: If input is:
anexample2.txt
the output is:
Please enter the name of the file:
Mjqqt Qnq~1 ~tz itnsl |jqqD
N,r knsj&&&&&
Qnkj nx tzwx yt gj xujsy1 sty yt gj xf{ji3
j mf{j mtuj3333 Wjgjqqntsx fwj gznqy ts mtuj3333
N kfnqji r~ |f~ yt xzhhjxx3
Ex: If the input is:
WrongFileName
the output is:
File does not exist](https://image.slidesharecdn.com/injavahowdoyouencodeandprinteachsentenceinthefileusinga-230313022048-66e37113/85/In-JAVA-how-do-you-encode-and-print-each-sentence-in-the-file-using-a-pdf-1-320.jpg)

The document explains how to encode and print sentences from a file using a basic Caesar cipher in Java, specifically by shifting each character's Unicode value by 5. It details handling input from multiple lines, outputting encoded sentences to a new text file named 'encoded.txt', and catching any IOExceptions. Sample outputs are provided to illustrate the encoded results and error handling for non-existent files.
![In JAVA how do you encode and print each sentence in the file using a basic Caesar Cipher.
- Encode the characters by shifting their Unicode value by 5
- For example if we encoded the character 'A' with a shift of 5 it would become the character 'F'
- For example if we encoded the character 'X' with a shift of 5 it would become the character ']'
- Spaces should be printed but not encoded
- Use the method caesarCipher
Write each encoded sentence to a new text file called encoded.txt
- If a IOException is thrown catch the exception and alert the user of the error
- Use the method encodedFile
(The main method cannot be set to throw any exceptions. The text file will contain multiple lines
and each line will correspond to a single sentence.)
Sample Output:
Ex: If input is:
anexample.txt
the output is:
Please enter the name of the file:
It tw it sty1 ymjwj nx st yw~&
Qnkj nx f qtsl qjxxts ns mzrnqny~3
Ex: If input is:
anexample2.txt
the output is:
Please enter the name of the file:
Mjqqt Qnq~1 ~tz itnsl |jqqD
N,r knsj&&&&&
Qnkj nx tzwx yt gj xujsy1 sty yt gj xf{ji3
j mf{j mtuj3333 Wjgjqqntsx fwj gznqy ts mtuj3333
N kfnqji r~ |f~ yt xzhhjxx3
Ex: If the input is:
WrongFileName
the output is:
File does not exist](https://image.slidesharecdn.com/injavahowdoyouencodeandprinteachsentenceinthefileusinga-230313022048-66e37113/85/In-JAVA-how-do-you-encode-and-print-each-sentence-in-the-file-using-a-pdf-1-320.jpg)
