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值对应的属性
Key |
Description of Associated Value |
java.version |
Java Runtime Environment version |
java.vendor |
Java Runtime Environment vendor |
java.vendor.url |
Java vendor URL |
java.home |
Java installation directory |
java.vm.specification.version |
Java Virtual Machine specification version |
java.vm.specification.vendor |
Java Virtual Machine specification vendor |
java.vm.specification.name |
Java Virtual Machine specification name |
java.vm.version |
Java Virtual Machine implementation version |
java.vm.vendor |
Java Virtual Machine implementation vendor |
java.vm.name |
Java Virtual Machine implementation name |
java.specification.version |
Java Runtime Environment specification version |
java.specification.vendor |
Java Runtime Environment specification vendor |
java.specification.name |
Java Runtime Environment specification name |
java.class.version |
Java class format version number |
java.class.path |
Java class path |
java.library.path |
List of paths to search when loading libraries |
java.io.tmpdir |
Default temp file path |
java.compiler |
Name of JIT compiler to use |
java.ext.dirs |
Path of extension directory or directories |
os.name |
Operating system name |
os.arch |
Operating system architecture |
os.version |
Operating system version |
file.separator |
File separator ("/" on UNIX) |
path.separator |
Path separator (":" on UNIX) |
line.separator |
Line separator ("\n" on UNIX) |
user.name |
User's account name |
user.home |
User's home directory |
user.dir |
User's current working directory |
如要得到当前目录,使用String dir = System.getProperty("user.dir");