I have a text file containing just lowercase letters and no punctuation except for spaces. I would like to know the best way of reading the file char by char, in a way that
If you want to read it whitout spliting the string - for example lines are too long, so you might encounter OutOfMemoryException, you should do it like this (using streamreader):
while (sr.Peek() >= 0)
{
c = (char)sr.Read();
if (c.Equals(' ') || c.Equals('\t') || c.Equals('\n') || c.Equals('\r'))
{
break;
}
else
word += c;
}
return word;