I can \"fix\" the below exception with a try-catch loop but I cannot understand the reason.
BufferedReader.readLine()
is declared as potentially throwing an exception, see: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/BufferedReader.html#readLine()
You either need to catch it, or declare your main method as throwing IOException.
Ie, either do this:
try {
while((s=in.readLine()) != null){
System.out.println(s);
}
} catch(IOException e) {
// Code to handle the exception.
}
Or
public static void main(String[] args) throws IOException { ...