The Java Tutorials' Weblog

pageicon Saturday Jul 25, 2009

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 now Path.deleteIfExists(). So, delete(true) is equivalent to delete(), and delete(false) is equivalent to deleteIfExists().
  • The time stamp methods in the Attribute class that took long, TimeUnit arguments now take an instance of the new FileTime class. Similarly, the BasicFileAttributes time stamp methods now return an instance of FileTime. The new method signatures are:
    • Attributes.setLastAccessTime(FileRef, FileTime)
    • Attributes.setLastModifiedTime(FileRef, FileTime)
    • FileTime creationTime() in BasicFileAttributes
    • FileTime lastAccessTime() in BasicFileAttributes
    • FileTime lastModifiedTime() in BasicFileAttributes
  • 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


« July 2009 »
SunMonTueWedThuFriSat
   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
26
27
28
29
30
31
 
       
Today

Feeds

Search this blog

Links

Weblog menu

Today's referrers

Today's Page Hits: 26