站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JDK 5 Documentation v1.4.0, Java 2 SDK 英文文档

NIO Beta 3 Changes - JDK 5 Documentation v1.4.0, Java 2 SDK 英文文档

Java

NIO APIs:
Beta 3 Changes

New I/O APIs
This document describes how the NIO APIs in the Beta 3 release of J2SE v 1.4 differ from those in Beta 2. The most significant change is a redesign of the java.nio.charset package to address the performance problems of the original design. A number of small adjustments have been made to the java.util.regex package to bring it into nearly perfect alignment with the regular-expression language implemented in Perl 5. The remaining changes are in response to feedback received from the community and issues raised within the Expert Group.

The changes are summarized by area:

Buffers

  • Added hasArray, array, and arrayOffset methods to all of the concrete buffer classes. (4503732)

  • Revised the specification of the MappedByteBuffer class to say that an attempt to access an inaccessible region of a mapped byte buffer will either return an arbitrary value (if reading) or have no visible effect (if writing); it will also cause an unspecified exception to be thrown either at the time of access or at some later time. (This is consistent with Sun's current implementation.)

  • Changed the static CharBuffer.wrap(String,int,int) and CharBuffer.wrap(String) methods to take a CharSequence rather than a String.

  • Added the ByteOrder.nativeOrder method, which is useful when setting up direct buffers that will be manipulated by native code.

  • Added order methods to each of the non-byte buffer classes (CharBuffer, ShortBuffer, IntBuffer, LongBuffer, FloatBuffer, and DoubleBuffer).

Files

  • Added the mode characters "s" and "d" to the RandomAccessFile constructors to allow the specification, at file-open time, of synchronous writes or synchronous-data writes.

  • Replaced the integer FileChannel.MAP_{RO,RW,COW} constants with the typesafe enumeration FileChannel.MapMode.

Selectors, selectable channels, and selection keys

Charsets

Regular expressions

  • Removed the conditional construct (?(cond)yes|no), since this is only an experimental feature in Perl. (4482696)

  • Removed < and > as metacharacters since they conflicted too easily with commonly-used tokens in HTML and XML. (4482696)

  • Removed vertical tab and form feed as line terminators. (4482696)

  • Added a new Pattern.UNIX_LINES mode, and the corresponding pattern flag (?d), that recognizes only newlines ('\n') as line terminators. (4482696)

  • Interpret dangling brackets ( ] ) and braces ( } ) as literals, as Perl does. (4482696)

  • Changed the way back references are parsed to more closely match the way Perl interprets them. (4482696)

  • Removed the cut operator (!), since this is not supported by Perl. (4482696)

  • Added the Pattern.COMMENTS mode, and the corresponding Perl-style pattern flag (?x), in which whitespace and comments can be embedded in a regular expression. (4482696)

  • Revised the character-class syntax to support the union and intersection of character classes via union ([X[Y]]), intersection ([X&&Y]), and complement ([^X]). (4482696)

  • Changed the ^ metacharacter so that it will not match after the final line terminator, since it does not do so in Perl. (4482696)

  • Revised all group constructs starting with (? so that they are treated as pure groups and do not capture text. (4482696)

  • Added the \G boundary matcher. (4470527)

  • Added Matcher.find(int startAt). (4474290)

  • Changed the replacement-string syntax in the Matcher class from $(n) to $n, and defined the escaping of $ to be more like Perl's. (4479128)

  • Revised the split methods in Pattern and String to match Perl's behavior. (4497806)

  • Revised the block/category syntax to match Perl's \p{Foo} and \P{Foo} syntax. (4495089)

  • Revised the names of the POSIX character classes to match the capitalized names used by Perl. (4495089)

  • Added String.matches(regex), a more convenient way to invoke Pattern.matches(regex, input).

  • Added String.replaceAll(regex, repl), a more convenient way to invoke Matcher.replaceAll(repl).

  • Added replaceFirst(regex, repl) methods to both String and Matcher.

  • Added description, pattern, and index properties to PatternSyntaxException.

Other


Copyright © 2001 Sun Microsystems, Inc. All Rights Reserved.

Sun
Java Software