+void MyApp::DoStreamDemo5(wxCommandEvent& WXUNUSED(event))
+{
+ wxTextCtrl& textCtrl = * GetTextCtrl();
+
+ textCtrl.Clear();
+ textCtrl << "\nTesting wxFileInputStream's Peek():\n\n";
+
+ char ch;
+ wxString str;
+
+ textCtrl.WriteText( "Writing number 0 to 9 to wxFileOutputStream:\n\n" );
+
+ wxFileOutputStream file_output( wxString("test_wx.dat") );
+ for (ch = 0; ch < 10; ch++)
+ file_output.Write( &ch, 1 );
+
+ file_output.Sync();
+
+ wxFileInputStream file_input( wxString("test_wx.dat") );
+
+ ch = file_input.Peek();
+ str.Printf( "First char peeked: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = file_input.GetC();
+ str.Printf( "First char read: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = file_input.Peek();
+ str.Printf( "Second char peeked: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = file_input.GetC();
+ str.Printf( "Second char read: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = file_input.Peek();
+ str.Printf( "Third char peeked: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = file_input.GetC();
+ str.Printf( "Third char read: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+
+ textCtrl << "\n\n\nTesting wxMemoryInputStream's Peek():\n\n";
+
+ char buf[] = { 0,1,2,3,4,5,6,7,8,9,10 };
+ wxMemoryInputStream input( buf, 10 );
+
+ ch = input.Peek();
+ str.Printf( "First char peeked: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = input.GetC();
+ str.Printf( "First char read: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = input.Peek();
+ str.Printf( "Second char peeked: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = input.GetC();
+ str.Printf( "Second char read: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = input.Peek();
+ str.Printf( "Third char peeked: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = input.GetC();
+ str.Printf( "Third char read: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+}
+