Hi guys,
I constantly got the same "Under no circumstances should null be returned" error, even though I run the main method to do local test and got exactly the same test result, i,e : "Hello Amigo #@)₴?$0"
Which part could I be wrong ??
package com.codegym.task.task32.task3213;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
/*
Caesar cipher
*/
public class Solution {
public static void main(String[] args) throws IOException {
StringReader reader = new StringReader("Khoor#Dpljr#&C,₷B'3");
System.out.println(decode(reader, -3)); // Hello Amigo #@)₴?$0
}
public static String decode(StringReader reader, int key) throws IOException {
BufferedReader bufferedReader = new BufferedReader(reader);
StringBuilder sb = new StringBuilder();
try{
int readin;
while ((readin = bufferedReader.read()) > 0){
sb.append((char)(readin + key));
}
}
catch (IOException e){
// "Under no circumstances should null be returned"
// return null;
}
return sb.toString();
}
}