1. Stream Zoo 的基礎:四個抽象類,InputStream, OutputStream, Reader, Writer
其中后面兩個使用于Unicode文本。
2. 四個接口
interface Closeable {void close() throws IOException}
interface Flushable {void flush() throws IOException}
這兩個比較簡單
interface Readable {int read(CharBuffer cb)}
其中CharBuffer提供了支持連續/隨機讀寫操作的方法
Appendable接口有兩個方法,用于追加單個字符或一列字符
Appendable append(char c)
Appendalbe append(CharSequence s)
CharSequence是另一個接口。
java.lang.CharSequence 1.4
char charAt(int index)
int length()
CharSequence subSequence(int startIndex, int endIndex)
String toString()
3. FileInputStream和FileOutputStream
構造方法:
FileInputStream fin = new FileInputStream("employee.dat");
或
File f = new File("employee.dat");
FileInputStream fin = new FileInputStream(f);
注意輸入Windows文件路徑的時候使用雙\\,如"C:\\Windows\\a.ini",不過也可以是"c:/Windows/a.ini",不過這并不被提倡。
讀入一個字節:byte b = (byte) fin.read();
3. System.getProperty 方法
public static String getProperty(String key)
返回key值對應的屬性