For reading input from STDIN i always used Scanner object. Recently I read about BufferedInputStream here that BufferedInputStream is fastest way to read input. In Scanner we have various methods (to read integer nextInt(), to read byte nextByte(), to read string next() etc.)
Currently i am reading some strings (at max 100000 characters) and some integers. According to these integers, i further run my for loop which takes input from the STDIN. Below is the code snippet which i use till now-
Scanner sc = new Scanner(System.in);
int numOfStr = sc.nextInt();
String inputStr[] = new String[numOfStr];
for (int i = 0; i < numOfStr; i++) {
inputStr[i] = sc.next();
}
}
However with BufferedInputStream we have only read() to read input. So how can i differentiate among the inputs? Can somebody please write down the BufferedInputStream code equivalent to the above Scanner ? Should i use StringTokenizer class to tokenize to data which i am getting from read() ? Will this not make the whole stuff (reading input from the STDIN) more slower than Scanner?