using System;
using System.IO;
class Extend
{
public static void Main( string[] args )
{
// create a file for testing
FileStream s = File.Create( "test.txt" );
s.Close();
// create MyWriter object
MyWriter write = new MyWriter( "test.txt" );
// write some integers to a file
Console.WriteLine(
"Writing the following integers: 4, 38764, 20948" );
write.WriteInteger( 4 );
write.WriteInteger( 38764 );
write.WriteInteger( 20948 );
// write some booleans
Console.WriteLine(
"Writing the following booleans: true, false" );
write.WriteBoolean( true );
write.WriteBoolean( false );
string day = "Have a nice day";
string year = "Happy new year!";
// write some strings
Console.WriteLine( "Writing the following strings: \""
+ day + "\", \"" + year + "\"" );
write.WriteString( day );
write.WriteString( year );
write.Close(); // close the file
MyReader read = new MyReader( "test.txt" );
// read integers back from the file
int firstInt = read.ReadInteger();
int secondInt = read.ReadInteger();
int thirdInt = read.ReadInteger();
Console.WriteLine( "\nRead the following integers: " +
"{0}, {1}, {2}", firstInt, secondInt, thirdInt );
// read booleans
bool firstBool = read.ReadBoolean();
bool secondBool = read.ReadBoolean();
Console.WriteLine( "Read the following booleans: " +
"{0}, {1}", firstBool, secondBool );
// read strings
string firstString = read.ReadString();
string secondString = read.ReadString();
Console.WriteLine( "Read the following strings: " +
"\"{0}\", \"{1}\"", firstString, secondString );
} // end Main
} // end class Extend