开发者

How to read character by character from text file?

开发者 https://www.devze.com 2023-02-06 20:34 出处:网络
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 chara

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

精彩评论

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