CSharp examples for File IO:String Reader Writer
Read a string as Reader
using System;/*from w w w .j a v a2 s .co m*/ using System.IO; using System.Text; public class Program { public static void Main(string[] args) { string input = "this is a test"; Console.WriteLine("Original text:\n{0}", input); StringReader reader = new StringReader(input); StringWriter writer = new StringWriter(); char[] buffer = new char[] { 'a'}; writer.Write(buffer); Console.WriteLine("\nWriting the chars to a StringWriter:\n{0}", writer.ToString()); const char SPACE = ' '; Console.WriteLine("\nReading the next char:"); char ch = (char)reader.Read(); if (ch == SPACE) { Console.WriteLine("\tNext char is a space character."); } else { Console.WriteLine(ch); } } }