Any idea why it works perfectly when I test it, but won't pass verification?
package com.codegym.task.task18.task1826;
/*
Encryption
*/
import java.io.*;
import java.util.ArrayList;
public class Solution {
public static void main(String[] args) throws IOException {
switch (args[0]) {
case "-e" : encryption(args[1], args[2]); //Encryption method
break;
case "-d" : decryption(args[2], args[1]); //decryption method
break;
default:break;
}
}
public static void encryption(String fileName, String fileOutput) throws IOException {
StringBuilder builder = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new FileReader(fileName)); BufferedWriter writer = new BufferedWriter(new FileWriter(fileOutput))){
while (reader.ready()) {
String data = reader.readLine();
builder.append(data);
}
char[] chars = builder.toString().toCharArray();
for (char i : chars) {
i+=7;
writer.write(i);
}
}
}
public static void decryption(String fileName, String fileOutput) throws IOException {
StringBuilder builder = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new FileReader(fileName)); BufferedWriter writer = new BufferedWriter(new FileWriter(fileOutput))){
while (reader.ready()) {
String data = reader.readLine();
builder.append(data);
}
char[] chars = builder.toString().toCharArray();
for (char i : chars) {
i-=7;
writer.write(i);
}
}
}
}