I hava exams in java and when I study I saw this excercise and I try to solve it but I found somne difficulity so please help me
Consider the following comment, header and partial code for a method in a utility
encryption class called Atbash.

    * Prompts the user for the pathname of a source .txt file to encrypt.
    * Prompts the user for the pathname of a destination .txt file
    * to which the encrypted text will be written.
    * The pathnames are then used to create two File objects.
    * The method then attempts to open streams on both files, one to
    * read from the source file, the other to write to the destination file.
    * The method then reads from the read stream a line at a time.
    * Each line read is converted to uppercase using the message
    * toUpperCase(). The method then constructs an encrypted string
    * into which all the alphabetic characters from the line are
    • substituted by their atbash equivalent, however any numeric or
    * punctuation characters are simply added unchanged to the encrypted
    * string. After each string is constructed it is written to the write
    * stream followed by a newline character.
    public static void encryptFile()
    OUDialog.alert("Please choose a file to encrypt");
    String pathname = OUFileChooser.getFilename();
    File aFile = new File(pathname);
    OUDialog.alert("Please give a file name for the encrypted file");
    String pathname2 = OUFileChooser.getFilename();
    File bFile = new File(pathname2);
    BufferedReader bufferedFileReader = null;
    BufferedWriter bufferedFileWriter = null;
    String currentLine;
    bufferedFileReader = new BufferedReader(new FileReader(aFile));
    bufferedFileWriter = new BufferedWriter(new FileWriter(bFile));
    String codedLine = "";
    char currentChar;
    currentLine = bufferedFileReader.readLine();
    while (//Boolean condition to be written as your answer for part (i))
/**this what I do while(currentLine!=null)*/

    //Statement block to be written as your answer for part (ii)

    catch (Exception anException)
    System.out.println("Error: " + anException);
    //Statement block to be written as your answer for part (iii)
  /* bufferedFileReader.close();
   *  bufferedFileWriter.close();

    catch (Exception anException)
    System.out.println("Error: " + anException);

(i) Write down the boolean condition for the while loop in the above method.



(ii) Write the code for the while statement block in the above method. This should
ensure that when the while loop has terminated, the destination .txt file contains
an encrypted version of the source .txt file. Your code should make use of the
variables bufferedFileReader, bufferedFileWriter, currentLine, codedLine,
currentChar, alphabet and mirror.
You may find the following two messages from the protocol of String useful:
charAt(int) which returns the char value at the index specified by the argument
and indexOf(char) which returns the index of the first occurrence of the
argument within the receiver.

(iii) Write the code for the final try block.


write anything as an answer to your ii question. do your best, and I am sure someone will help you. it's a norm here to only help those that show effort. you haven't shown any. sorry bud!

This article has been dead for over six months. Start a new discussion instead.