How do I read input line by line in Java? I searched and so far I have this:
import java.util.Scanner;
public class MatrixReader {
public static void main(S
The previously posted suggestions have typo (hasNextLine spelling) and new line printing (println needed each line) issues. Below is the corrected version --
import java.util.Scanner;
public class XXXX {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while (input.hasNextLine()){
System.out.println(input.nextLine());
}
}
}