开发者

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();
     }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜