第一级别:精读源码
java.io
Provides for system input and output through data streams, serialization and the file system.
Ensential interfaces
- DataInput: binary stream->bytes->java primitive type
- DataOutput: java primitive type->bytes->binary stream
- Serializable: mark as serializable
- FileNameFilter
- FileFilter
Ensential classes
- IO流
- InputStream/OutputStream<-->Reader/Writer
- BufferedInputStream/BufferedOutputStream<-->BufferedReader/BufferedWriter
- ByteArrayInputStream/ByteArrayOutputStream<-->CharArrayReader/CharArrayWriter
- PipeInputStream/PipeOutputStream<-->PipeReader/PipeWriter
- FileInputStream/FileOutputStream<-->FileReader/FileWriter
- FilterInputStream/FilterOutputStream<-->FilterReader/FilterWriter
- StringBufferInputStream<-->StringReader/StringWriter
- DataInputStream/DataOutputStream
- ObjectInputStream/ObjectOutputStream
- PriterWriter/PriterReader
- SequenceInputStream
Main Useage
一、按数据来源(去向)分类:
- 是文件: FileInputStream, FileOutputStream, ( 字节流 )FileReader, FileWriter( 字符 )
- 是 byte[] : ByteArrayInputStream, ByteArrayOutputStream( 字节流 )
- 是 Char[]: CharArrayReader, CharArrayWriter( 字符流 )
- 是 String: StringBufferInputStream, StringBufferOuputStream ( 字节流 )StringReader, StringWriter( 字符流 )
- 网络数据流: InputStream, OutputStream,( 字节流 ) Reader, Writer( 字符流 )
二、按是否格式化输出分:
- 要格式化输出: PrintStream, PrintWriter
三、按是否要缓冲分:
- 要缓冲: BufferedInputStream, BufferedOutputStream,( 字节流 ) BufferedReader, BufferedWriter( 字符流 )
四、按数据格式分:
- 二进制格式(只要不能确定是纯文本的) : InputStream, OutputStream 及其所有带 Stream 结束的子类
- 纯文本格式(含纯英文与汉字或其他编码方式); Reader, Writer 及其所有带 Reader, Writer 的子类
五、按输入输出分:
- 输入: Reader, InputStream 类型的子类
- 输出: Writer, OutputStream 类型的子类
六、特殊需要:
- 从 Stream 到 Reader,Writer 的转换类: InputStreamReader, OutputStreamWriter
- 对象输入输出: ObjectInputStream, ObjectOutputStream
- 进程间通信: PipeInputStream, PipeOutputStream, PipeReader, PipeWriter
- 合并输入: SequenceInputStream
- 更特殊的需要: PushbackInputStream, PushbackReader, LineNumberInputStream, LineNumberReader
决定使用哪个类以及它的构造进程的一般准则如下(不考虑特殊需要):
- 考虑最原始的数据格式是什么: 原则四
- 是输入还是输出:原则五
- 是否需要转换流:原则六第 1 点
- 数据来源(去向)是什么:原则一
- 是否要缓冲:原则三 (特别注明:一定要注意的是 readLine() 是否有定义,有什么比 read, write 更特殊的输入或输出方法)
- 是否要格式化输出:原则二
- File and FileDescriptor
java.lang
Provides classes that are fundamental to the design of the Java programming language.
Ensential interfaces
- Comparable
- Iterable
- Runnable
Ensenti classes
- Object
- Number
- Boolean/Byte/Short/Integer/Long/Float/Double/Character
- Class/ClassLoader
- Enum/StrictMath/Math
- Package/Void/Runtime/Throwable
- Process/ProcessBuilder/Thread/ThradLocal/ThreadGroup
- System/SecurityManager
- String/StringBuffer(很多方法加了synchronized)/StringBuilder
java.util
Contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array).
Ensential interfaces
image- Collection/Set/SortedSet/List/ListIterator/Deque/Queue/SortedMap/Map/Map.Entry
- Comparator
- Enumeration
- EventListener
- Iterator
Ensenti classes
第二级别:深刻理解
- java.lang.reflect
- java.net
- javax.net.*
- java.nio.*
- java.util.concurrent.*
第三级别:会用即可
- java.lang.annotation
- javax.annotation.*
- java.lang.ref
- java.math
- java.rmi.*
- javax.rmi.*
- java.security.*
- javax.security.*
- java.sql
- javax.sql.*
- javax.transaction.*
- java.text
- javax.xml.*
- org.w3c.dom.*
- org.xml.sax.*
- javax.crypto.*
- javax.imageio.*
- javax.jws.*
- java.util.jar
- java.util.logging
- java.util.prefs
- java.util.regex
- java.util.zip
网友评论