import java.util.Scanner; class MyClass { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int employeeId,
What you can do is use delimeter as new line. Till you press enter key you will be able to read it as string.
Scanner sc = new Scanner(System.in); sc.useDelimiter(System.getProperty("line.separator"));
Hope this helps.