本文主要是《Introduction to Java Programming, Comprehensive Version (9th Edition)》的读书笔记。
--坚持,近2000页的英文电子书!
1、 You should not let the method terminate the program—the caller should decide whether to terminate the program.
这是关于异常处理的一句话,可见如果被调用函数出现异常,对于如何处理这个异常应该交由调用者处理,而不是被调用函数自己在内部处理,被调用函数要做的应该是检测异常的出现,之后将之throw给调用者。
2、感悟:读写本地文件跟读写网络文件本质上都是从某个地方读写文件,如果忽略网络连接的细节,读写本地文件的所有操作都应该可以对应到读写网络上的某个文件,所以不要把从web抓取网页、远程访问等一些概念吓住,本质上都是读取、写入一些数据到某个地方,只是多了一些具体细节的复杂性,但是往往这些复杂性已经被封装在了很多常用的函数中。
3、The modified UTF-8 scheme stores a character using one, two, or three bytes.
Characters are coded in one byte if their code is less than or equal to 0x7F, in two bytes if
their code is greater than 0x7F and less than or equal to 0x7FF, or in three bytes if their
code is greater than 0x7FF.
The initial bits of a UTF-8 character indicate whether a character is stored in one byte, two
bytes, or three bytes. If the first bit is 0, it is a one-byte character. If the first bits are 110, it is
the first byte of a two-byte sequence. If the first bits are 1110, it is the first byte of a three-byte
sequence.
The information that indicates the number of characters in a string is stored in the
first two bytes preceding the UTF-8 characters. For example, writeUTF("ABCDEF") actually
writes eight bytes (i.e., 00 06 41 42 43 44 45 46) to the file, because the first two
bytes store the number of characters in the string.