using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
class Program {
static void Main(string[] args) {
byte[] byData;
char[] charData;
try {
FileStream aFile = new FileStream("Temp.txt", FileMode.Create);
charData = "www.java2java.com".ToCharArray();
byData = new byte[charData.Length];
Encoder e = Encoding.UTF8.GetEncoder();
e.GetBytes(charData, 0, charData.Length, byData, 0, true);
aFile.Seek(0, SeekOrigin.Begin);
aFile.Write(byData, 0, byData.Length);
} catch (IOException ex) {
Console.WriteLine(ex.ToString());
return;
}
}
}
|