NET Intermediate Class--file, stream, serialization 2

Source: Internet
Author: User

1. Flow type system:

Base stream Adorner flow wrapper class helper class

2. Stream

file~ memory~ network~

Stream is an abstract class in which the method is either abstract or virtual

3. Adorner flow : inherits from the Stream class and contains a reference to the Stream class. such as BufferedStream GZipStream

The purpose of Adorner mode: To add functionality to an existing class.

4. wrapper class : Note The class, not the stream. That is, they are not stream types but contain a reference to the stream, providing an easy way to manipulate the convection.

Used to read the contents of a file.

The TextReader TextWriter is a base class that is independent of the stream and defines the way in which character data is read and written.

StreamReader Streadwriter is a subclass. StreamReader: Reads the contents of the stream as characters. Streamwrite writes a character to the stream.

Stringreader,stringwirte is also a subclass, but it just reads and processes the string without processing the stream.

string [email protected] "Product: Lumia 920                         Price: 4998"; StringReader reader=new StringReader (text); int c =reader.read (); Console.Write ((char) c);   Output: Production char[]  buffer=new char[8];rader.read (buffer,0,buffer.length); Console.Write (String.Join ("", buffer));// Product: Lumia  //Assume that the text string above is saved in the file  as long as the Stringreder is replaced with Streamreaderfilestream fs=new filestrem (...); StreamReader reader=new StreamReader (Fs,encoding.getencode ("GB2312"));

  Encoding method: All involved in text files must have coding problems. The encoding defines how the bytes are converted into readable characters or text. It can be imagined that the corresponding relational table of bytes and characters.

5. The Help class is not very close to the flow, but it can make the file stream operation simple.

File FileInfo Path Directory Diretoryinfo

FileStream fs=file.create ("1.txt");

  

NET Intermediate Class--file, stream, serialization 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.