码迷,mamicode.com
首页 > 其他好文 > 详细

7.0 Streams

时间:2015-05-04 23:55:02      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:

When I worked on Lab-1, I used Streams, though I hadn‘t learned that.

And this time, let me talk about more details of Streams.

First, let‘s have a look at a piece of codes.

//ImplementingBinaryReadWriteToFile

 技术分享

In the above codes, we copy a .txt file FFFF.txt to a new-built .txt file COPY.txt

Following are two files in the given directory. And they have the same contents. 

技术分享

技术分享

//Implementing buffered I/O

技术分享

This time, we still copy the .txt file FFFF.txt, too. However, we used a new way, that is, we copy the file by implementing BufferedStream.

We get the same result, though.

技术分享

//Reading and Writing to a text file

技术分享

The third time, we finished the same function but this time we used Streams specially for the text file.

And this time, I write the output to the console which is the content of the copied file, FFFF.txt. We can also find the new file that copy from FFFF.txt in the directory.

 技术分享

(Don‘t amazed by the content, it‘s just some error message that occurred when I ran another program before,,,,,,~) 

//Warning!

// While using Streams, don‘t forget to Close() the Streams after we complete our work with them.

-----------------END & TO BE CONTINUED-----------------

 

7.0 Streams

标签:

原文地址:http://www.cnblogs.com/lyli/p/4477700.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!