The Java Tutorials' Weblog
NIO.2 Updates in JDK7
If you are already using the new file I/O API provided in JDK7, you should be aware that there are some minor API changes as of build 64. If you are using the JavaOne Preview release, the changes have not yet been integrated, but they are available now on java.net.The API is changed as follows:
Path.delete(boolean)is nowPath.deleteIfExists(). So,delete(true)is equivalent todelete(), anddelete(false)is equivalent todeleteIfExists().- The time stamp methods in the
Attributeclass that tooklong, TimeUnitarguments now take an instance of the newFileTimeclass. Similarly, theBasicFileAttributestime stamp methods now return an instance of FileTime. The new method signatures are:Attributes.setLastAccessTime(FileRef, FileTime)Attributes.setLastModifiedTime(FileRef, FileTime)FileTime creationTime()inBasicFileAttributesFileTime lastAccessTime()inBasicFileAttributesFileTime lastModifiedTime()inBasicFileAttributes
- The
BasicFileAttribute.linkCount()method has been removed. - The
BasicFileAttribute.resolution()method has been removed.
The File I/O lesson in the Java Tutorials has been updated with the new API.
-- Sharon Zakhour
Posted at 09:39AM Jul 25, 2009 by The Java Tutorial Team | Comments[2]
Saturday Jul 25, 2009
Nice job. My own attempt was less personal, and therefore would have been less effective.
Has anyone looked at JavaFX, jRuby or Scala as scripting languages that could simplify coding for these new NIO features? Just curious.
Posted by milt brewster on August 14, 2009 at 10:34 AM PDT #
Thanks, Milt. :)
I don't know the answer to that question.
Posted by Sharon Zakhour on August 17, 2009 at 09:02 AM PDT #