I am trying to take some user input and process them in my program. For that using the Scanner class as below.
Scanner scan = new Scanner(System.in);
System.out.print("Input : ");
String input = scan.nextLine();
// Process the Data
scan.close();
The program works fine with small amount of data. But if the input string length is huge (~100K characters), Scanner stops responding and fails to read any data.
Is there any different way or workaround to this problem ?
Note : These is no possible way to store the data in a file and read from there. It would be a nice option to read chunks of data from a file. But unfortunately there is no such implementation in my application.
EDIT : As mentioned earlier, I need to read data directly from user (not from a file). Anyway, already tried to use the BufferReader. But does not seem like can read some data of around 100K characters.
Here is the code below.
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Input : ");
String input = br.readLine();
// Remaining Code