
Table of Contents
Dedication ............................................................................................................................. 1
Preface ................................................................................................................................... 2
Organization ....................................................................................................................... 3
Who Should Read This Book............................................................................................. 5
Software and Versions ....................................................................................................... 5
Conventions Used in This Book......................................................................................... 6
How to Contact Us ............................................................................................................. 7
Acknowledgments.............................................................................................................. 8
Chapter 1. Introduction..................................................................................................... 10
1.1 I/O Versus CPU Time ................................................................................................ 10
1.2 No Longer CPU Bound .............................................................................................. 11
1.3 Getting to the Good Stuff ........................................................................................... 12
1.4 I/O Concepts............................................................................................................... 13
1.5 Summary .................................................................................................................... 21
Chapter 2. Buffers ..............................................................................................................22
2.1 Buffer Basics .............................................................................................................. 23
2.2 Creating Buffers ......................................................................................................... 36
2.3 Duplicating Buffers .................................................................................................... 38
2.4 Byte Buffers ............................................................................................................... 40
2.5 Summary .................................................................................................................... 52
Chapter 3. Channels........................................................................................................... 54
3.1 Channel Basics ........................................................................................................... 55
3.2 Scatter/Gather............................................................................................................. 62
3.3 File Channels.............................................................................................................. 67
3.4 Memory-Mapped Files............................................................................................... 80
3.5 Socket Channels ......................................................................................................... 91
3.6 Pipes ......................................................................................................................... 109
3.7 The Channels Utility Class....................................................................................... 114
3.8 Summary .................................................................................................................. 115
Chapter 4. Selectors ......................................................................................................... 117
4.1 Selector Basics ......................................................................................................... 117
4.2 Using Selection Keys ............................................................................................... 125
4.3 Using Selectors......................................................................................................... 128
4.4 Asynchronous Closability ........................................................................................ 137
4.5 Selection Scaling ...................................................................................................... 138
4.6 Summary .................................................................................................................. 143
Chapter 5. Regular Expressions ..................................................................................... 145
5.1 Regular Expression Basics ....................................................................................... 145
5.2 The Java Regular Expression API............................................................................ 147
5.3 Regular Expression Methods of the String Class..................................................... 168
5.4 Java Regular Expression Syntax .............................................................................. 169
5.5 An Object-Oriented File Grep.................................................................................. 172
5.6 Summary .................................................................................................................. 178
Chapter 6. Character Sets ............................................................................................... 180
6.1 Character Set Basics................................................................................................. 180
6.2 Charsets .................................................................................................................... 182
6.3 The Charset Service Provider Interface ................................................................... 201
6.4 Summary .................................................................................................................. 214
评论2