public static string ReadLine( TextReader reader )
{
string line = reader.ReadLine();
if ( line != null )
{
line = line.Replace( "\t", " " );
line = line.Trim();
// ignore blank lines, lines without spaces, or comments
if ( line.Length == 0 || line.IndexOf( ' ' ) == -1 || line.StartsWith( "//" ) )
{
return line;
}
StringBuilder sb = new StringBuilder();
string[] values = line.Split( ' ' );
// reduce big space gaps between values down to a single space
for ( int i = 0; i < values.Length; i++ )
{
string val = values[ i ];
if ( val.Length != 0 )
{
sb.Append( val + " " );
}
}
line = sb.ToString();
line = line.TrimEnd();
} // if
return line;
}