How to simulate Java Scanner next () method in a C # stream?

There is a method in the Java scanner next()that reads the next token from the stream, where the token is something separated by delimiters (by default, the delimiter is any space character, including a tab and a new line).

How can I do this using C # /. NET? A thread in C # has Read()and ReadLine(), but they don't have a space or user separator concept. I can read the whole line and then use the string method Split(), but that means I have to read the whole line first (unlike next(), which only reads the next token).

+3
source share
1 answer

, , . , StreamReader , (.. , ). StringBuilder " " , , .

, , , , , . , StringBuilder , , .

, Scanner - . , IEnumerable<string> . , Func<TextReader>, TextReader, .

+4

All Articles