Memory stream is an excellent class to hold your content temporarily in our server memory. Following code snippet can be used as a starter of how to use it:
// write out new page in memory stream
MemoryStream stream = new MemoryStream();
StreamWriter writer =new StreamWriter(stream);
writer.WriteLine("<html><body>");
writer.WriteLine("Hello, World");
writer.WriteLine("</body></html>");
writer.Flush();
// add new page to site
SPWeb site = SPContext.Current.Web;
site.Files.Add("hello.htm", stream);
94d8ab63-9d11-4103-ac1a-2066b9af01fe|0|.0