Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am decoding a message that I have read in from a file but I want to save the d

ID: 3539015 • Letter: I

Question

I am decoding a message that I have read in from a file but I want to save the decoded message to a different file. I am able to get my code to read character by character onto the screen but how do I save this to a file? Do I need to store it into an array? I want to return my decoded message so that I can call it to a different method which I have already where I save it to a file. Or, would it be best to save it to a file in this method?

Here is my method..I think that I want it to return the decoded message so I would have to set it up differently.

private static void decodeMessage(String phrase) {

int temp;

phrase = phrase.toUpperCase();

for (int i = 0; i < phrase.length(); i++) {

if (Character.isLetter(phrase.charAt(i))) {

for (int j = 0; j < alpha.length; j++) {

if (phrase.charAt(i) == alpha[j]) {

if (j == 0) {

System.out.print(alpha[alpha.length - 1]);

} else {

System.out.print(alpha[j - 1]);

temp=(alpha[j-1]);//I thought that If I stored it here and return this to my main method it would work??? THEN RETURN TEMP?????************

System.out.println(temp);

  

}

}

}

} else {

System.out.print(phrase.charAt(i));

}

}

System.out.println();

  

}

Explanation / Answer

Hi, I dont want yo spoon feed u, but ig it helps, google 'writing to file in java mkyong'

If u still need help, reach me at eyedagger@gmail.com , m a tutor, wud surely help u out