using System;
using [Link];
class MyReader : StreamReader
{
// default constructor
public MyReader( string fileName )
: base( fileName )
{
} // end constructor
// read in integer from file
public int ReadInteger()
{
// for reading an integer
char[] buffer = new char[ 10 ];
int input = 0;
string toRead = [Link];
// read 10 characters representing an integer from the file
Read( buffer, 0, 10 );
toRead = new string( buffer );
try
{
input = [Link]( toRead );
} // end try
catch ( Exception )
{
return 0;
} // end catch
return input;
} // end method ReadInteger
// read in boolean from file
public bool ReadBoolean()
{
// for reading a boolean
char[] buffer = new char[ 5 ];
string toRead = [Link];
// read either 'true' or 'false'
Read( buffer, 0, 5 );
toRead = new string( buffer );
return [Link]() == "true";
} // end method ReadBoolean
// read in string from file
public string ReadString()
{
// for reading a string
char[] buffer = new char[ 1 ];
string input = [Link];
// each string is separated by "ENDOFSTRING";
// read in one character at a time until termination
// string is reached
while ( [Link]( "ENDOFSTRING" ) == -1 )
{
Read( buffer, 0, 1 );
input += buffer[ 0 ];
} // end while
// trim the termination string off the read string
return [Link]( 0, [Link]( "ENDOFSTRING" ) );
} // end method ReadString
} // end class MyReader