A simple solution would be to use Scanner class.
See snipet below:
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
while(s.hasNextLine())
{
String line = s.nextLine();
System.out.println(line);
}
}
}