NIO APIs:
|
New I/O APIs |
This document describes how the NIO APIs in the RC release of J2SE v 1.4 differ from those in Beta 3. The changes are summarized by area:Buffers
Revised the type-specific buffer classes (
ByteBuffer
,CharBuffer
, etc.) to implement theComparable
interface. They already defined the necessarycompareTo
methods.Revised the type-specific buffer classes to make it impossible to access the backing array of a non-direct heap buffer. Invoking the
hasArray
method of such a buffer will always return false. Invoking thearray
orarrayOffset
methods of such a buffer will cause aReadOnlyBufferException
to be thrown.Channels (general)
Revised the
Channel
interface by moving the functionality of asynchronous closing and interruption to the new interfaceInterruptibleChannel
, renamed the SPI class AbstractChannel toAbstractInterruptibleChannel
, and revised that class to implementInterruptibleChannel
. As a consequence of these changes all of the public channel classes now implement the new interface, while methods such asChannels.newChannel
can return channels that are readable or writable but not necessarily interruptible.Revised the
Pipe.SourceChannel
class to implement theScatteringByteChannel
interface, and revised thePipe.SinkChannel
class to implement theGatheringByteChannel
interface.Revised the
read
methods of theGatheringByteChannel
interface and thewrite
methods of theScatteringByteChannel
interface to returnlong
rather thanint
byte counts. Corresponding changes were also made to theDatagramChannel
,FileChannel
, andSocketChannel
classes.File channels
Revised the
transferTo
andtransferFrom
methods to take long rather than intcount
parameters, and to return long rather than int byte counts, so that they can be used to transfer large files. Revised themap
method's size parameter to be long rather than int for consistency.Other
The changes described in this section were made in the 1.4 RC release but not described in this document until the 1.4 FCS release. For further details, see the JSR-51 Change Log.
- Added a security check to the CharsetProvider constructor. We defined a new runtime security permission, charsetProvider, and revised the CharsetProvider constructor to throw a
SecurityException
if the security manager refuses permission.
- Replaced the insecure CharsetProvider method putCharsets with a new method named
charsets
. The new method creates an iterator for the charsets supported by the provider.
- Added a security check to the SelectorProvider constructor.
- Removed the setProvider method of SelectorProvider. Trusted code can still declare its own selector provider as the system-wide default by setting a system property on the command line or making a provider available as a service. (The specification of the provider method describes the lookup algorithm in detail.)
- Declared
public static
fields in CodingErrorAction to befinal
.
Copyright © 2002 Sun Microsystems, Inc. All Rights Reserved. Please send comments to: java-io@java.sun.com |
Java Software |