コード例 #1
0
        public void appendFile()
        {
            string       tempFile = Path.GetTempFileName();
            BufferedSink sink     = EasyIO.Buffer(EasyIO.Sink(tempFile, FileMode.Append));

            sink.WriteUtf8("Hello, ");
            sink.Dispose();
            Assert.True(File.Exists(tempFile));
            Assert.AreEqual(7, File.ReadAllText(tempFile).Length);

            sink = EasyIO.Buffer(EasyIO.Sink(tempFile, FileMode.Append));
            sink.WriteUtf8("easy.io file!");
            sink.Dispose();
            Assert.AreEqual(20, File.ReadAllText(tempFile).Length);

            BufferedSource source = EasyIO.Buffer(EasyIO.Source(tempFile));

            Assert.AreEqual("Hello, easy.io file!", source.ReadUtf8());
            source.Dispose();
        }
コード例 #2
0
 public void Dispose()
 {
     if (closed)
     {
         return;
     }
     try
     {
         sink.Dispose();
     }
     catch
     {
     }
     closed = true;
 }
コード例 #3
0
        public void readWriteFile()
        {
            string       tempFile = Path.GetTempFileName();
            BufferedSink sink     = EasyIO.Buffer(EasyIO.Sink(tempFile));

            sink.WriteUtf8("Hello, easy.io file!");
            sink.Dispose();
            Assert.True(File.Exists(tempFile));
            var allText = File.ReadAllText(tempFile);

            Assert.AreEqual(20, allText.Length);
            BufferedSource source = EasyIO.Buffer(EasyIO.Source(tempFile));

            Assert.AreEqual("Hello, easy.io file!", source.ReadUtf8());
            source.Dispose();
        }