import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
public class Test {
public static void main(String[] args) throws UnsupportedEncodingException {
BufferedReader br = null;
InputStreamReader reader = new InputStreamReader(System.in);
br = new BufferedReader(reader);
String buffer = null;
try {
while((buffer = br.readLine()) != null){
System.out.println("输入的内容为:"+buffer);
}
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

还有另一种更简单的方法:

Scanner scanner = new Scanner(System.in);

String inputStr = scanner.nextLine();

System.out.println(inputStr);