I’m writing code in Intelij. readLine does not correctly read the input (puts a line break at the end of the line), which is why the next readline does not work (becomes automatically empty).
Code:
public class Start {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String s = reader.readLine();
ArrayList<String> list = new ArrayList<>();
while (true) {
if (s == null || s.isEmpty()) {
break;
}
else list.add(s);
s = reader.readLine();
}
for (String str : list) {
System.out.println(str);
}
If important: LF separator and UTF-8 encoding
>Solution :
It’s a know bug. The fix is already available, please update.