没有合适的资源?快使用搜索试试~ 我知道了~
首页High Performance Java IO And Regular Expressions 高性能JAVA IO 与正则表达式
High Performance Java IO And Regular Expressions 高性能JAVA IO 与正则表...

High Performance Java IO And Regular Expressions 高性能JAVA IO 与正则表达式
资源详情
资源评论
资源推荐

Java New I/O
High Performance Java I/O And Regular Expressions
*** AUTHOR'S DRAFT, Do Not Copy ***
by Ron Hitchens

Java New I/O: High Performance Java I/O And Regular Expressions:
*** AUTHOR'S DRAFT, Do Not Copy ***
by Ron Hitchens
Copyright © 2002 Ron Hitchens
This book is an examination of the New I/O (NIO) packages added to the Java Platform in the 1.4 release.


Table of Contents
Preface....................................................................................................................................................................
Organization ........................................................................................................................................ 13
Who Should Read This Book .............................................................................................................. 14
Software and Versions ........................................................................................................................ 15
Conventions Used In This Book ......................................................................................................... 15
Font Conventions ............................................................................................................. 16
Comments and Questions .................................................................................................................... 17
Acknowledgements ............................................................................................................................. 18
1Introduction.........................................................................................................................................................
I/O vs CPU Time ................................................................................................................................. 1
No Longer CPU Bound ....................................................................................................................... 2
Getting To The Good Stuff ................................................................................................................. 3
I/O Concepts ........................................................................................................................................ 3
Buffer Handling ............................................................................................................... 4
Scatter/Gather ............................................................................................... 5
Virtual Memory ................................................................................................................ 6
Memory Paging ................................................................................................................ 7
File I/O ............................................................................................................................. 9
Memory Mapped Files .................................................................................. 10
File Locking .................................................................................................. 11
Stream I/O ........................................................................................................................ 12
Summary ............................................................................................................................................. 13
2Buffers.................................................................................................................................................................
Buffer Basics ....................................................................................................................................... 15
Attributes .......................................................................................................................... 15
Buffer API ........................................................................................................................ 16
Accessing ......................................................................................................................... 17
Filling ............................................................................................................................... 18
Flipping ............................................................................................................................ 19
Draining ........................................................................................................................... 20
Compacting ...................................................................................................................... 22
Marking ............................................................................................................................ 23
Comparing ........................................................................................................................ 24
Bulk Moves ...................................................................................................................... 28
Creating Buffers .................................................................................................................................. 30
Duplicating Buffers ............................................................................................................................. 32
Byte Buffers ........................................................................................................................................ 34
Byte Ordering ................................................................................................................... 36
Direct Buffers ................................................................................................................... 39
View Buffers .................................................................................................................... 40
Data Element Views ......................................................................................................... 42
Accessing Unsigned Data ................................................................................................ 45
Memory Mapped Buffers ................................................................................................. 46
Summary ............................................................................................................................................. 46
3Channels..............................................................................................................................................................
Channel Basics .................................................................................................................................... 51
Opening Channels ............................................................................................................ 51
Using Channels ................................................................................................................ 52
Closing Channels ............................................................................................................. 56
Scatter/Gather ...................................................................................................................................... 58

File Channels ....................................................................................................................................... 63
Accessing Files ................................................................................................................ 66
File Locking ..................................................................................................................... 70
Example Code Using File Locking ............................................................... 72
Memory Mapped Files ..................................................................................................... 75
Example Code Using MappedByteBuffer and Gathering Writes ......... 79
Channel-To-Channel Transfers ........................................................................................ 83
Socket Channels .................................................................................................................................. 85
Non-Blocking Mode ......................................................................................................... 87
ServerSocketChannel ............................................................................................ 88
SocketChannel ........................................................................................................... 90
DatagramChannel ...................................................................................................... 93
Example DatagramChannel Code .......................................................... 97
Pipes .................................................................................................................................................... 102
The Channels Utility Class ............................................................................................................. 107
Summary ............................................................................................................................................. 108
4Selectors..............................................................................................................................................................
Selector Basics .................................................................................................................................... 112
The Selector, SelectableChannel and SelectionKey Classes ................... 113
Setting Up Selectors ......................................................................................................... 116
Using Selection Keys .......................................................................................................................... 118
Using Selectors .................................................................................................................................... 121
The Selection Process ...................................................................................................... 121
Stopping the Selection Process ........................................................................................ 123
Managing Selection Keys ................................................................................................ 124
Concurrency ..................................................................................................................... 128
Asynchronous Closability ................................................................................................................... 129
Selection Scaling ................................................................................................................................. 129
Summary ............................................................................................................................................. 134
5RegularExpressions............................................................................................................................................
Regular Expression Basics .................................................................................................................. 137
The Java Regular Expression API ....................................................................................................... 138
The CharSequence Interface ...................................................................................... 138
The Pattern Class ........................................................................................................ 140
Splitting Strings With The Pattern Class ................................................. 145
The Matcher Class ........................................................................................................ 148
Regular Expression Methods of the String Class ........................................................................... 159
Java Regular Expression Syntax ......................................................................................................... 160
An Object-Oriented File Grep ............................................................................................................. 163
Summary ............................................................................................................................................. 168
6CharacterSets......................................................................................................................................................
Character Set Basics ............................................................................................................................ 169
Charsets ............................................................................................................................................... 171
The Charset Class ........................................................................................................ 174
Comparing Charsets ......................................................................................................... 176
Charset Encoders .............................................................................................................. 177
The CoderResult Class .................................................................................. 182
Character Encoding Example ....................................................................... 183
Charset Decoders ............................................................................................................. 186
Character Decoding Example ....................................................................... 189
The Charset Service Provider Interface .......................................................................................... 191
Creating Custom Charsets ................................................................................................ 192
Providing Your Custom Charsets .................................................................................... 194
Custom Charset Example ................................................................................................. 196
剩余254页未读,继续阅读


















安全验证
文档复制为VIP权益,开通VIP直接复制

评论2