Java IO 概述
InputStream,OutputStream,Reader和Writer
需要从某些源读取数据的程序需要InputStream或Reader。 需要向某些目的地写入数据的程序需要一个OutputStream或Writer。
Java IO目的和功能:
Java IO包含InputStream,OutputStream,Reader和Writer类的许多子类。 原因在于,所有这些子类正在解决各种不同的目的。 这就是为什么有这么多不同的课程。 所述目的总结如下:
- File Access
- Network Access
- Internal Memory Buffer Access
- Inter-Thread Communication (Pipes)
- Buffering
- Filtering
- Parsing
- Reading and Writing Text (Readers / Writers)
- Reading and Writing Primitive Data (long, int etc.)
- Reading and Writing Objects
讨论了源,目的地,输入,输出以及Java IO类目标的各种IO目的,这里列出了大部分(如果不是全部)Java IO类除以输入,输出,基于字节或基于字符的表,以及任何 更具体的目的,他们可能正在解决,如缓冲,解析等
| 类型 | 字节 | 字节 | 字符 | 字符 |
| ------------- |:-------------|: -----|: -----|: -----|
| |Input | Output| Input | Output |
| basic| InputStream | OutStream|Reader / InputStreamReader | Writer / OutputStreamWriter |
| Arrays| ByteArrayInputStream | ByteArrayOutputStream | CharArrayReader| CharArrayWriter |
| Files| FileInputStream / RandomAccessFile | FileOutputStream / RandomAccessFile | FileReader | FileWriter |
| Pipes| PipedInputStream | PipedOutputStream | PipedReader | PipedWriter |
| Buffering | BufferedInputStream | BufferedOutputStream | BufferedReader | BufferedWriter |
| Filtering | FilterInputStream | FilterOutputStream | FilterReader | FilterWriter |
| Parsing | PushbackInputStream / StreamTokenizer| |PushbackReader / LineNumberReader | |
| Strings| | |StringReader | StringWriter |
| Data| DataInputStream | DataOutputStream | | |
| Data - Formatted | | PrintStream | | PrintWriter |
| Objects | ObjectInputStream | ObjectOutputStream| | |
| Utilities| SequenceInputStream | | | |
网友评论