mirror of
https://github.com/LingCoder/OnJava8.git
synced 2026-08-31 03:38:07 +08:00
更新附录部分章节子标题
This commit is contained in:
@@ -1,7 +1,32 @@
|
||||
[TOC]
|
||||
|
||||
<!-- Appendix: Becoming a Programmer -->
|
||||
# 附录:成为一名程序员
|
||||
|
||||
|
||||
<!-- How I Got Started in Programming -->
|
||||
## 如何开始
|
||||
|
||||
|
||||
<!-- A Career in Computing -->
|
||||
## 码农生涯
|
||||
|
||||
|
||||
<!-- The Mythical 5% -->
|
||||
## 百分之五的神话
|
||||
|
||||
|
||||
<!-- Writing Software Is Like … Writing -->
|
||||
## 重在动手
|
||||
|
||||
|
||||
<!-- Programming as Typing -->
|
||||
## 像打字般编程
|
||||
|
||||
|
||||
<!-- Do What You Love -->
|
||||
## 做你喜欢的事
|
||||
|
||||
<!-- 分页 -->
|
||||
|
||||
<div style="page-break-after: always;"></div>
|
||||
@@ -1,7 +1,29 @@
|
||||
[TOC]
|
||||
|
||||
<!-- Appendix: Benefits and Costs of Static Type Checking -->
|
||||
# 附录:静态语言类型检查
|
||||
|
||||
|
||||
<!-- Foreword -->
|
||||
## 前言
|
||||
|
||||
|
||||
<!-- Static Type Checking vs. Testing -->
|
||||
## 静态类型检查和测试
|
||||
|
||||
|
||||
<!-- How to Argue about Typing -->
|
||||
## 如何提升打字
|
||||
|
||||
|
||||
<!-- The Cost of Productivity -->
|
||||
## 生产力的成本
|
||||
|
||||
|
||||
<!-- Static vs. Dynamic -->
|
||||
## 静态和动态
|
||||
|
||||
|
||||
<!-- 分页 -->
|
||||
|
||||
<div style="page-break-after: always;"></div>
|
||||
@@ -1,7 +1,78 @@
|
||||
[TOC]
|
||||
|
||||
<!-- Appendix: Collection Topics -->
|
||||
# 附录:集合主题
|
||||
|
||||
|
||||
<!-- Sample Data -->
|
||||
## 示例数据
|
||||
|
||||
|
||||
<!-- List Behavior -->
|
||||
## List表现
|
||||
|
||||
|
||||
<!-- Set Behavior -->
|
||||
## Set表现
|
||||
|
||||
|
||||
<!-- Using Functional Operations with any Map -->
|
||||
## 在Map中使用函数式操作
|
||||
|
||||
|
||||
<!-- Selecting Parts of a Map -->
|
||||
## 选择Map的部分
|
||||
|
||||
|
||||
<!-- Filling Collections -->
|
||||
## 集合的fill方法
|
||||
|
||||
|
||||
<!-- Custom Collection and Map using Flyweight -->
|
||||
## 使用Flyweight自定义集合和Map
|
||||
|
||||
|
||||
<!-- Collection Functionality -->
|
||||
## 集合功能
|
||||
|
||||
|
||||
<!-- Optional Operations -->
|
||||
## 可选操作
|
||||
|
||||
|
||||
<!-- Sets and Storage Order -->
|
||||
## Set和存储顺序
|
||||
|
||||
|
||||
<!-- Queues -->
|
||||
## 队列
|
||||
|
||||
|
||||
<!-- Understanding Maps -->
|
||||
## 理解Map
|
||||
|
||||
|
||||
<!-- Utilities -->
|
||||
## 集合工具类
|
||||
|
||||
|
||||
<!-- Holding References -->
|
||||
## 持有引用
|
||||
|
||||
|
||||
<!-- Java 1.0/1.1 Collections -->
|
||||
## 避免旧式类库
|
||||
|
||||
|
||||
<!-- Summary -->
|
||||
## 本章小结
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- 分页 -->
|
||||
|
||||
<div style="page-break-after: always;"></div>
|
||||
@@ -1,7 +1,20 @@
|
||||
[TOC]
|
||||
|
||||
<!-- Appendix: Data Compression -->
|
||||
# 附录:数据压缩
|
||||
|
||||
|
||||
<!-- Simple Compression with GZIP -->
|
||||
## 使用Gzip简单压缩
|
||||
|
||||
|
||||
<!-- Multifile Storage with Zip -->
|
||||
## 使用zip多文件存储
|
||||
|
||||
|
||||
<!-- Java Archives (Jars) -->
|
||||
## Java的jar
|
||||
|
||||
<!-- 分页 -->
|
||||
|
||||
<div style="page-break-after: always;"></div>
|
||||
@@ -1,7 +1,37 @@
|
||||
[TOC]
|
||||
|
||||
<!-- Appendix: I/O Streams -->
|
||||
# 附录:流式IO
|
||||
|
||||
|
||||
<!-- Types of InputStream -->
|
||||
## 输入流类型
|
||||
|
||||
|
||||
<!-- Types of OutputStream -->
|
||||
## 输出流类型
|
||||
|
||||
|
||||
<!-- Adding Attributes and Useful Interfaces -->
|
||||
## 添加属性和有用的接口
|
||||
|
||||
|
||||
<!-- Readers & Writers -->
|
||||
## Reader和Writer
|
||||
|
||||
|
||||
<!-- Off By Itself: RandomAccessFile -->
|
||||
## RandomAccessFile类
|
||||
|
||||
|
||||
<!-- Typical Uses of I/O Streams -->
|
||||
## IO流典型用途
|
||||
|
||||
|
||||
<!-- Summary -->
|
||||
## 本章小结
|
||||
|
||||
|
||||
<!-- 分页 -->
|
||||
|
||||
<div style="page-break-after: always;"></div>
|
||||
@@ -1,5 +1,6 @@
|
||||
[TOC]
|
||||
|
||||
<!-- Appendix: Javadoc -->
|
||||
# 附录:文档注释
|
||||
|
||||
<!-- 分页 -->
|
||||
|
||||
@@ -1,4 +1,42 @@
|
||||
[TOC]
|
||||
|
||||
<!-- Appendix: Low-Level Concurrency -->
|
||||
# 附录:并发底层原理
|
||||
|
||||
|
||||
<!-- What is a Thread? -->
|
||||
## 线程
|
||||
|
||||
|
||||
<!-- Catching Exceptions -->
|
||||
## 异常捕获
|
||||
|
||||
|
||||
<!-- Sharing Resources -->
|
||||
## 资源共享
|
||||
|
||||
|
||||
<!-- The volatile Keyword -->
|
||||
## volatile关键字
|
||||
|
||||
|
||||
<!-- Atomicity -->
|
||||
## 原子性
|
||||
|
||||
|
||||
<!-- Critical Sections -->
|
||||
## 关键部分
|
||||
|
||||
|
||||
<!-- Library Components -->
|
||||
## 库组件
|
||||
|
||||
|
||||
<!-- Summary -->
|
||||
## 本章小结
|
||||
|
||||
|
||||
|
||||
<!-- 分页 -->
|
||||
<div style="page-break-after: always;"></div>
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
[TOC]
|
||||
|
||||
<!-- Appendix: New I/O -->
|
||||
# 附录:新IO
|
||||
|
||||
|
||||
@@ -11,7 +12,9 @@ Java “新” I/O 库,是在Java 1.4引入到 **Java .nio.* package** 中。
|
||||
|
||||
本附录将深入探讨 nio 包。像I/O streams 这样的高级库使用 **nio**,但是大多数时候您不需要在这个级别使用 I/O 。在Java 7和Java 8,您(理想情况下)除了特殊情况外,甚至不需要使用I/O流。理想情况下,您将经常使用的所有内容都包含在文件一章中。只有在处理性能问题 (例如,可能需要内存映射文件)或创建自己的 I/O 库时,才需要理解 **nio**。
|
||||
|
||||
## ByteBuffers
|
||||
<!-- ByteBufferS -->
|
||||
## ByteBuffer
|
||||
|
||||
|
||||
直接与通道通信的缓冲区只有一个类型,就是 bytebuffer 。也就是说,一个保存原始字节的缓冲区。如果您查看 **java.nio.ByteBuffer** 的JDK文档,你会发现它很基本 : 您可以通过告诉它要分配多少存储空间来创建一个方法,并且可以使用一些方法来放置和获取数据,这些方法可以是原始字节形式的数据,也可以是原始数据类型的数据。但是没有办法放置或获取对象,甚至字符串。它是相当低层次的,因为这使得大多数操作系统的映射更加有效。
|
||||
|
||||
@@ -162,10 +165,11 @@ public class TransferTo {
|
||||
|
||||
你不会经常这样做,但知道这一点很好。
|
||||
|
||||
<!-- Converting Data -->
|
||||
|
||||
<!-- Converting Data -->
|
||||
## 转换数据
|
||||
|
||||
|
||||
在 **GetChannel** 中打印文件中的信息。在 java 中,我们每次提取一个字节的数据,并将每个字节转换为 char。这看起来很简单——如果您查看**java.nio.CharBuffer** 类,您将看到它有一个toString()方法,该方法说,“返回一个包含这个缓冲区中的字符的字符串。”
|
||||
|
||||
既然 **ByteBuffer** 可以用 **asCharBuffer()** 方法看作 **CharBuffer**,为什么不使用它呢? 从下面输出语句的第一行可以看出,这并不正确:
|
||||
@@ -322,10 +326,11 @@ gb2312-1980
|
||||
|
||||
由于每个字符需要两个字节,这对于12个字符已经足够了,但是“some text”只有9个字节。其余的零字节仍然出现在由其toString()生成的CharBuffer的表示中,如输出所示。
|
||||
|
||||
<!-- Fetching Primitives -->
|
||||
|
||||
<!-- Fetching Primitives -->
|
||||
## 获取原始类型
|
||||
|
||||
|
||||
虽然 **ByteBuffer** 只包含字节,但它包含了一些方法,用于从它所包含的字节中生成每种不同类型的基元值。这个例子展示了使用以下方法插入和提取各种值:
|
||||
|
||||
```java
|
||||
@@ -395,9 +400,9 @@ H o w d y !
|
||||
这将对每个基本数据类型执行。其中唯一有点奇怪的是 **ShortBuffer** 的 **put()**,它需要强制转换 (强制转换并更改结果值)。所有其他视图缓冲区都不需要在它们的 **put()** 方法中强制转换。
|
||||
|
||||
<!-- View Buffers -->
|
||||
|
||||
## 视图缓冲区
|
||||
|
||||
|
||||
“视图缓冲区”通过特定原始类型的窗口来查看底层 **ByteBuffer**。**ByteBuffer** 仍然是“支持”视图的实际存储,因此对视图所做的任何更改都反映在对 **ByteBuffer** 中的数据的修改中。
|
||||
|
||||
如前面的示例所示,这方便地将基本类型插入 **ByteBuffer**。视图缓冲区还可以从 **ByteBuffer** 读取原始值,一次读取一个(ByteBuffer允许),或者批量读取(数组)。下面是一个通过 **IntBuffer**在**ByteBuffer** 中操作 int 的例子:
|
||||
@@ -569,9 +574,9 @@ public class Endians {
|
||||
**charArray** 通过 **CharBuffer** 视图插入到 **ByteBuffer **中。当显示底层字节时,默认顺序与随后的大端序相同,而小端序则交换字节。
|
||||
|
||||
<!-- Data Manipulation with Buffers -->
|
||||
|
||||
## 使用缓冲区进行数据操作
|
||||
|
||||
|
||||
下图说明了 nio 类之间的关系,展示了如何移动和转换数据。例如,要将字节数组写入文件,使用ByteBuffer.wrap() 方法包装字节数组,使用 **getChannel()** 在 **FileOutputStream** 上打开通道,然后从 **ByteBuffer** 将数据写入 **FileChannel**。
|
||||
|
||||

|
||||
@@ -663,9 +668,9 @@ position 指向缓冲区中的第一个元素,capacity 和 limie 紧接在最
|
||||
再次调用 **symmetricgrab()** 函数时,**CharBuffer** 将经历相同的过程并恢复到原始状态。
|
||||
|
||||
<!-- Memory-Mapped Files -->
|
||||
|
||||
## 内存映射文件
|
||||
|
||||
|
||||
内存映射文件允许您创建和修改太大而无法放入内存的文件。使用内存映射文件,您可以假装整个文件都在内存中,并将其视为一个非常大的数组来访问它。这种方法大大简化了您编写的修改文件的代码:
|
||||
|
||||
```java
|
||||
@@ -864,8 +869,8 @@ Mapped Read/Write: 0.013
|
||||
请注意,**test()** 方法包括初始化各种I/O对象的时间,因此,尽管映射文件的设置可能很昂贵,但是与流I/O相比,总体收益非常可观。
|
||||
|
||||
<!-- File Locking -->
|
||||
## 文件锁定
|
||||
|
||||
### 文件锁定
|
||||
|
||||
文件锁定同步访问,因此文件可以是共享资源。但是,争用同一个文件的两个线程可能位于不同的jvm 中,可能一个是 Java 线程,另一个是操作系统中的某个本机线程。文件锁定对其他操作系统进程是可见的,因为Java文件锁定直接映射到本机操作系统锁定工具。
|
||||
|
||||
|
||||
@@ -1,7 +1,22 @@
|
||||
[TOC]
|
||||
|
||||
<!-- Appendix: Object Serialization -->
|
||||
# 附录:对象序列化
|
||||
|
||||
|
||||
<!-- Finding the Class -->
|
||||
## 查找类
|
||||
|
||||
|
||||
<!-- Controlling Serialization -->
|
||||
## 控制序列化
|
||||
|
||||
|
||||
<!-- Using Persistence -->
|
||||
## 使用持久化
|
||||
|
||||
|
||||
|
||||
<!-- 分页 -->
|
||||
|
||||
<div style="page-break-after: always;"></div>
|
||||
@@ -1,7 +1,30 @@
|
||||
[TOC]
|
||||
|
||||
<!-- Appendix: Passing and Returning Objects -->
|
||||
# 附录:对象传递和返回
|
||||
|
||||
|
||||
<!-- Passing References -->
|
||||
## 传递引用
|
||||
|
||||
|
||||
<!-- Making Local Copies -->
|
||||
## 本地拷贝
|
||||
|
||||
|
||||
<!-- Controlling Cloneability -->
|
||||
## 控制克隆
|
||||
|
||||
|
||||
<!-- Immutable Classes -->
|
||||
## 不可变类
|
||||
|
||||
|
||||
<!-- Summary -->
|
||||
## 本章小结
|
||||
|
||||
|
||||
|
||||
<!-- 分页 -->
|
||||
|
||||
<div style="page-break-after: always;"></div>
|
||||
@@ -1,7 +1,18 @@
|
||||
[TOC]
|
||||
|
||||
<!-- Appendix: Programming Guidelines -->
|
||||
# 附录:编程指南
|
||||
|
||||
|
||||
<!-- Design -->
|
||||
## 设计
|
||||
|
||||
|
||||
<!-- Implementation -->
|
||||
## 实现
|
||||
|
||||
|
||||
|
||||
<!-- 分页 -->
|
||||
|
||||
<div style="page-break-after: always;"></div>
|
||||
@@ -1,7 +1,11 @@
|
||||
[TOC]
|
||||
|
||||
<!-- Appendix: Standard I/O -->
|
||||
# 附录:标准IO
|
||||
|
||||
<!-- Process Control -->
|
||||
## 执行控制
|
||||
|
||||
<!-- 分页 -->
|
||||
|
||||
<div style="page-break-after: always;"></div>
|
||||
@@ -15,6 +15,6 @@
|
||||
<!-- Hands-On Java eSeminar -->
|
||||
## 动手实践
|
||||
|
||||
<!-- 分页 -->
|
||||
|
||||
<!-- 分页 -->
|
||||
<div style="page-break-after: always;"></div>
|
||||
@@ -1,8 +1,8 @@
|
||||
[TOC]
|
||||
|
||||
<!-- Appendix: The Positive Legacy of C++ and Java -->
|
||||
# 附录:C++和Java的优良传统
|
||||
|
||||
<!-- 分页 -->
|
||||
|
||||
<div style="page-break-after: always;"></div>
|
||||
|
||||
|
||||
@@ -1,7 +1,19 @@
|
||||
[TOC]
|
||||
|
||||
<!-- Appendix: Understanding equals() and hashCode() -->
|
||||
# 附录:理解equals和hashCode方法
|
||||
|
||||
<!-- 分页 -->
|
||||
|
||||
<!-- A Canonical equals() -->
|
||||
## equals典范
|
||||
|
||||
|
||||
<!-- Hashing and Hash Codes -->
|
||||
## 哈希和哈希码
|
||||
|
||||
|
||||
<!-- Tuning a HashMap -->
|
||||
## 调整HashMap
|
||||
|
||||
<!-- 分页 -->
|
||||
<div style="page-break-after: always;"></div>
|
||||
Reference in New Issue
Block a user