I don\'t quite understand how different they are from each other so I have some inquiries regarding these two packages.
After looking around a bit on Google, it seems li
Java started initially by offering the File
class, in the java.io
package to access file systems. This object represents a file/directory and did allow you to perform some operations such as checking if a file/directory exists, get properties and delete it. It had, though, some shortcomings. To name a few:
boolean
. As one can imagine, in case of an error, false
was returned, rather than throwing an exception. The developer had, indeed, no way of knowing why it failed.To overcome these problems, java.nio package was introduced in java 4. The key features were:
With java 7 the java.nio.file package is introduced providing a better support for handling symbolic links, file attributes access and specially to support extended the file system through classes such as Path, Paths and Files. You might wanna to have a look at the java.nio.file package description to get further details on this.
With this in mind:
What are some big changes from NIO to NIO.2? (e.g. new methods, features)?
They serve different purposes. To point out big changes you might want to look at the all new package java.nio.file
.
Why did the original NIO package have to be updated?
It didn't. A new package was introduced rather than updated.
Is NIO.2 just synonymous with the NIO package nowadays? How does the performance of NIO package compare with the NIO.2 package?
No, they are not synonymous. It also does not make much sense to compare performance between them, as they serve different purposes. NIO a more abstract low level data I/O and NIO2 focused on file management.
Hope this helps.
[Bibliography: Oracle Certified Professional Java SE7 - A comprehensive OCJP7 Certification Guide, by S.G.Ganesh and Tushar Sharma - Chapter 9]