JDK source code of the IO of

2010-06-29  来源:本站原创  分类:Java  人气:179 

A typical IO operation is the read InputStream and OutputStream to wite (byte b) as the standard, InputStream time to receive one or more bytes, while the OutputStream will write one or more bytes.
Emerged from JDK1.1 to start operating as a standard character Reader and Write, Reader first to read one or more characters, while the Writer to write one or more characters. The IO operations are carried out around this topic.
InputStream:
ByteArrayInputStream
FileInputStream
ObjectInputStream
PipedInputStream
SequenceInputStream
StringBufferInputStream, outdated, in the old version to read a byte. Reader has been replaced by the corresponding subclass
FilterInputStream
BufferedInputStream
......

OutputStream:
ByteArrayOutputStream
FilterOutputStream
BufferedOutputStream
......
FileOutputStream
ObjectOutputStream
PipedOutputStream

Reader:
BufferedReader
CharArrayReader
InputStreamReader
PipedReader
StringReader

Writer:
BufferedWriter
CharArrayWriter
OutputStreamWriter
PipedWriter
PrintWriter
StringWriter
1, InputStreamReader InputStream byte stream is a bridge leading characters flow through the packing InputStream to Reader can read the character way.
2, OutputStreamWriter is a character stream OutputStream bridge leading to a byte stream through the packing OutputStream can write characters the way to Writer.
3, FileInputStream and FileOutputStream classes are two more special, the two classes InputStream to OutputStream were holding a reference, through the decorated model, can easily add some extra features.
BufferedInputStream and BufferedOutputStream is a subclass of the two provides a buffer and reduce the interaction with the physical device.
4, Reader and Writer can not Stream less complex, BufferedReader and BufferedWriter, were directly inherited from the Reader and Writer classes.
5, Reader and Writer is a platform default character encoding to read or write, the need to specify the encoding used InputStreamReader and OutputstreamWriter.
6, who is due to the use of decorative patterns, was created IO code written today layers of packaging, "unsightly." The layers of packaging requires no special memory, has its own characteristics.
When you need to use files based on byte stream stream new FileInputStream, the outer disk plus a BufferedInputStream to reduce interaction with, then became the InputStream = new BufferedInputStream (new FileInputStream ()); OutputStream also the same reason;
When you need to use character-based stream file stream new FileReader, also need to add buffer, then a new BufferedReader (new FileReader ()). Need to specified encoding, then a new BufferedReader (new InputStreamReader (new FileInputStream (path), encoding));
7, InputStream, OutputStream, Reader, Writer are the abstract class
8, ObjectInputStream and ObjectOutputStream basic types are used for reading and writing.

相关文章
  • JDK source code of the IO of 2010-06-29

    A typical IO operation is the read InputStream and OutputStream to wite (byte b) as the standard, InputStream time to receive one or more bytes, while the OutputStream will write one or more bytes. Emerged from JDK1.1 to start operating as a standard

  • JDK source code of the concurrent 2010-06-29

    ava.util.concurrent package contains the framework of Java concurrent programming solution 1, synchronized: each object in JAVA actually has a hidden lock object, as to the method with the equivalent of the object when szhcnronized with synchronized

  • JDK source code of the sql package 2010-06-29

    java.sql 1, JDBC is a set of protocols, is JAVA developers and database vendor agreement, that is, a set of interfaces defined by the Sun, by the database vendor to implement, and provides for JAVA developers to access the database used by the method

  • By analyzing the source code of JDK TreeMap Red-black tree algorithm 2010-09-01

    Reprinted from: https: / / www.ibm.com/developerworks/cn/java/j-lo-tree/ Description: TreeMap and TreeSet Java Collection Framework is two important members of the Map interface, which is commonly used TreeMap implementation class, which is the Set i

  • By analyzing the source code of JDK red-black tree algorithm TreeMap 2011-05-04

    By analyzing the source code of JDK red-black tree algorithm TreeMap Li Gang , a freelance writer Introduction: TreeMap and TreeSet Java Collection Framework is two important members of the Map interface, which is commonly used TreeMap implementation

  • How to view the JDK class library in the Eclipse source code 2010-07-21

    Set: 1. Point "window" -> "Preferences" -> "Java" -> "Installed JRES" 2. Then "Installed JRES" is the right list pane, lists the system JRE environment, choose your JRE, then the edge of the "

  • Java source code and recommended books to read! 2009-11-16

    1. Java language based on On the basis of Java language learning books, I am sure you will recommend Bruce Eckel's "Thinking in Java". It is written in a very profound technical books, Java language is not based on any other part of the capital

  • Tomcat 5.5.26 source code analysis - start the process (2) 2010-03-25

    init method Catalina_Home and Catalina_Base Initialize the system class loader Tomcat's class loader system initClassLoaders code Two questions Catalina Object load method Catalina class command-line arguments Loading process start Method await state

  • Spring2.5 + JPA (Hibernate3.2) source code examples (CTO) 2009-10-17

    In this paper, to cut-off since I CSDN blog http://blog.csdn.net/ctojxzsycztao/archive/2009/05/12/4171730.aspx Today, because of Busy came about JPA studied , and gave a simple example to small for you to share, first of all, we come to a brief intro

  • JSON for Java source code 2010-03-29

    Look at the source code is distributed together with you to explore the inadequacies of the wing please. 1. Test file: test.json /** * Test JSON * */ { id:-NaN, //ID $name_1:"johnson\" Lee \"+\"test\"", // Name married:false,

  • ubuntu9.10 next download and compile source code of android 2010-03-29

    For a long time did not update your blog, and put under the ubuntu9.10 write down the steps to compile the source code to facilitate future access to: sudo apt-get install git-core curl sudo apt-get install gcc g + + flex bison gperf libsdl1.2-dev li

  • pure IP database QQwry.dat reading java source code (change) 2010-03-29

    pure IP database QQwry.dat reading java source code, to run this program must go to download QQwry.da, due to too much, I am not here to provide a. 1, IPEntry.java / ** * * An IP range of records, including not only national and regional, but also th

  • Stack and Java-based class Stack class implementation source code, defects and how to achieve your Stack class 2010-03-29

    The stack is an important data structure, data structure from the point of view, the stack is a linear form, its uniqueness in the basic operation of the stack is a subset of a linear form. Stack as the most basic data structure, the code in the JDK,

  • JAVA source code of arbitrary structure builder CodeMaster v1.0 Beta 2009-01-27

    Download See attachment struts attached minimum system to run. CodeMaster is an intelligent code generation gadgets, using pure java development, small and simple but in many cases very useful, in theory, any structure can generate java source code,

  • Get android source code 2008-05-07

    android's source code is very large http://android.git.kernel.org/ Official Website The following passage To clone one of these trees, install git, and Run: git clone git://android.git.kernel.org/ + project path. To clone the entire Platform, install

  • ThreadLocal Source Code Analysis 2009-09-17

    Had previously been associated ThreadLocal reproduced the article, but it has been in a confused state, when the chance to see the recent review of the blog's article, it made for such an in-depth analysis and summary. (Also note, I am the source of

  • Spring source code analysis (1): IOC Container 2010-02-11

    In the Spring of, IOC important position of the container we can not say, and for Spring users in terms of, IOC container in fact what is it? BeanFactory we can say is what we have seen IoC container, Spring of course for us to prepare a lot of kinds

  • Red5 source code analysis (reproduced semi-sleep) 2010-03-25

    Red5 how to respond to the request rmpt, in the middle What are the key classes involved? To respond to the request process is as follows: 1.Red5 will start calling RTMPMinaTransport the start () method, which will open a socket listening rmtp port (

  • Mysql source code analysis series 2010-03-30

    Mysql source code analysis series (2): the source code structure Mysql source code include the client code, server-side code, testing tools and some database structure, the following directories we do introduce the more important. BUILD This director

  • Lucene-2.2.0 source code reading to learn (1) 2010-04-01

    package org.apache.lucene.demo; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.index.IndexWriter; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Date; / /