Lec11 - Java File IO.pdf - Unauthorized reproduction or...

This preview shows page 1 - 5 out of 60 pages.

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.Java File I/O (NIO.2)Peter Muturi ([email protected]ฺacฺke) has a non-transferable license touse this Student GuideฺUnauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ
Java SE 7 Programming 11 - 2Copyright © 2012, Oracle and/or its affiliates. All rights reserved.ObjectivesAfter completing this lesson, you should be able to:Use the Pathinterface to operate on file and directory pathsUse the Filesclass to check, delete, copy, or move a file or directoryUse Filesclass methods to read and write files using channel I/O and stream I/ORead and change file and directory attributesRecursively access a directory treeFind a file by using thePathMatcherclassPeter Muturi ([email protected]ฺacฺke) has a non-transferable license touse this Student GuideฺUnauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ
NIO API in JSR 51 established the basis for NIO in Java, focusing on buffers, channels, and charsets. JSR 51 delivered the first piece of the scalable socket I/Os into the platform, providing a non-blocking, multiplexed I/O API, thus allowing the development of highly scalable servers without having to resort to native code.For many developers, the most significant goal of JSR 203 is to address issues with java.io.Fileby developing a new file system interface. The new API:Works more consistently across platformsMakes it easier to write programs that gracefully handle the failure of file system operationsProvides more efficient access to a larger set of file attributesAllows developers of sophisticated applications to take advantage of platform-specific features when absolutely necessaryAllows support for non-native file systems, to be “plugged in” to the platformJava SE 7 Programming 11 - 3Copyright © 2012, Oracle and/or its affiliates. All rights reserved.New File I/O API (NIO.2)Improved File System InterfaceComplete Socket-Channel FunctionalityScalable Asynchronous I/OPeter Muturi ([email protected]ฺacฺke) has a non-transferable license touse this Student GuideฺUnauthorized reproduction or distribution prohibitedฺ Copyright© 2013, Oracle and/or its affiliatesฺ
The Java I/O File API (java.io.File) presented challenges for developers. Many methods did not throw exceptions when they failed, so it was impossible to obtain a useful error message. Several operations were missing (file copy, move, and so on).The rename method did not work consistently across platforms.There was no real support for symbolic links.More support for metadata was desired, such as file permissions, file owner, and other security attributes.Accessing file metadata was inefficient—every call for metadata resulted in a system call, which made the operations very inefficient.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture