How can I input many lines in Java without knowing what is the limit of input? This is for competitive programming.
For example this input
4568
3258
124569
14789
I have to read all in one click, but how is that possible if I don't know the limit of input lines that I receive? Maybe next time I'll receive 34.
I was looking for something and I have this, but it didn't work:
Scanner sc = new Scanner(System.in);
String text;
while(sc.hasNextLine()){
text = sc.nextLine();
}