There are several improvements to the standard(java.nio.charset.Charset) and extended charsetimplementations. They include:
NewSelectorProvider implementation for Solaris based on the Solaris event port mechanism. ThisSelectorProvider may improve performance or scalability for some server workloads. The/dev/poll SelectorProvider continues to be the default. To use the Solaris event port mechanism, run with the system propertyjava.nio.channels.spi.Selector set to the valuesun.nio.ch.EventPortSelectorProvider.
Decrease in the size of<JDK_HOME>/jre/lib/charsets.jar file
Performance improvement for thejava.lang.String(byte[], *) constructor and thejava.lang.String.getBytes() method.
Thejava.nio.filepackage and its related package,java.nio.file.attribute,provide comprehensive support for file I/O and for accessing thefile system. A zip file system provider is also available in JDK 7.The following resources provide more information:
<Javahome>/sample/nio/chatserver/ contains samples thatdemonstrate the new APIs contained in thejava.nio.file package<Javahome>/demo/nio/zipfs/ contains samples thatdemonstrate the NIO.2 NFS (Network File System) file systemIn addition, the following enhancement is introduced:
Area: NIO
Standard/Platform: JDK 7
Synopsis: Prior to the JDK 7 release, direct buffersallocated usingjava.nio.ByteBuffer.allocateDirect(int)were aligned on a page boundary. In JDK 7, the implementation haschanged so that direct buffers are no longer page aligned. Thisshould reduce the memory requirements of applications that createlots of small buffers.
RFE:4837564
One new class is provided:
Console -Contains methods to access a character-based console device. ThereadPassword() methods disable echoing thus they aresuitable for retrieval of sensitive data such as passwords. ThemethodSystem.console()returns the unique console associated with the Java VirtualMachine.The following new methods were added toFile:
getTotalSpace()returns the size of the partition in bytesgetFreeSpace()returns the number of unallocated bytes in the partitiongetUsableSpace()returns the number of bytes available on the partition and includeschecks for write permissions and other operating systemrestrictionssetWritable(boolean writable, boolean ownerOnly) andsetWritable(booleanwritable) set the owner's or everybody's writepermissionsetReadable(boolean readable, boolean ownerOnly) andsetReadable(booleanreadable) set the owner's or everybody's readpermissionsetExecutable(boolean executable, boolean ownerOnly) andsetExecutable(booleanexecutable) set the owner's or everybody's executepermissioncanExecute()tests the value of the execute permissionConstructors were added to the following class:
IOExceptionsupports exception chaining via the addition of the newconstructorsIOException(String, Throwable) andIOException(Throwable).The behavior of the following method was modified:
File.isFile()Windows implementation has been modified to always returnfalse for reserved device names such as CON, NUL, AUX,LPT, etc. Previously it returnedtrue, which customersconsidered a bug because it was inconsistent with behavior fordevices on UNIX.java.nio.channels.SelectorProviderimplementation that is based on the Linux epoll event notificationfacility is included. The epoll facility is available in the Linux2.6, and newer, kernels. The new epoll-basedSelectorProvider implementation is more scalable thanthe traditional poll-basedSelectorProviderimplementation when there are thousands ofSelectableChannelsregistered with aSelector.The newSelectorProvider implementation will be usedby default when the 2.6 kernel is detected. The poll-basedSelectorProvider will be used when a pre-2.6 kernel isdetected.sun.nio.ch.disableSystemWideOverlappingFileLockCheckcontrols whetherjava.nio.channels.FileChannel.lock()checks whether regions are locked by other instances ofFileChannel. Unless this system property is set totrue,FileChannel.lock() will throw anOverlappingFileLockException if an application attemptsto lock a region that overlaps one that is locked by anotherinstance ofFileChannel. The system property exists toprovide compatibility with previous releases which do not implementthe JVM-wide overlapping file lock check.javax.net.ssl.SSLEnginewas added. The existing J2SDK 1.4.0 secure communicationinfrastructure,javax.net.ssl.SSLSocket,was based on the I/O model of java.net.Socket. TheSSLEngine class abstracts away the I/O model, andleaves developers free to secure communication pathways usingalternate types of I/O.SSLEngine can be combined withthe New I/O APIs to create implementations such as secure blockingor non-blockingSocketChannels. For details see theJSSE ReferenceGuide.FileInputStreamandFileOutputStreamclasses,getChannel methods have been added to returnthe underlyingFileChannel object, and theclose methods have been revised to close theunderlying channel.RandomAccessFileclass, agetChannel method has been added and theclose method has been revised to close the underlyingchannel. TheRandomAccessFile constructors now supportthe mode characters"s" and"d" to allow thespecification, at file-open time, of synchronous writes orsynchronous-data writes.InputStreamReaderandOutputStreamWriterclasses, constructors have been added that take a stream and aCharset object, and thegetEncodingmethods have been revised to return the historical name of theencoding being used. Constructors toInputStreamReaderandOutputStreamWriter have been added that takeexistingCharsetDecoder andCharsetEncoder objects, respectively.NewDirectByteBuffer,GetDirectBufferAddress, andGetDirectBufferCapacity.java.io.File class.java.io package.