Preparing Secret Messages

Many historical secret codes are designed to encrypt only letters of the alphabet -- not digits or punctuation.

Write a class called MessagePreparer whose main method will use the JFileChooser class to prompt the user to select a text file that represents some secret message to be prepared for encryption. The title of the resulting dialog box should be "Choose a text file to prepare...". A copy of the text in the user-selected file should be made, with the following alterations:

  • All characters that are not letters or spaces should be removed.
  • All letters should be converted, if necessary, to lowercase.
  • Any occurrences of "James Bond", or simply "Bond", should be replaced with a less-identity-revealing "double o seven". This includes upper-case and lower-case variations on the same.

The altered text should be saved to a new file in the parent directory of the original file, and given the name "readyToEncrypt.txt" (unless this file already exists) , and the user should be made aware that the new file was created through a message displayed via the JOptionPane class. If a file with that name already exists in the current directory, no action should be taken, and a JOptionPane should be used to inform the user that no action was taken, and why.

Sample run:

Content of file named sampleMessage.txt...
James Bond has discovered secret Hydra hideout in Cuba -- Bond is heading there now.  Please have "Q" prepare the normal supplies for his arrival. "M" will serve as a contact on this end. Please restore Bond's status to that previously held. Are there any additional orders?
Content of file named readyToEncrypt.txt produced...
double o seven has discovered secret hydra hideout in cuba  double o seven is heading there now  please have q prepare the normal supplies for his arrival m will serve as a contact on this end please restore double o sevens status to that previously held are there any additional orders