How to read character by character from text file?
How to read charac开发者_如何学JAVAter by character in line from text file?
Use the StraemReader class. It has a Read() method that reads the next character from the input stream and advances the character position by one character. (Overrides TextReader.Read().)
For example:
using (StreamReader sr = new StreamReader(path))
{
while (sr.Peek() >= 0)
{
char c = (char)sr.Read();
}
}
精彩评论