IO (input/output) has been around since the beginning of Java and one could read and write files along with some other common operations.
Then with Java 1.4, Java added more
I/O functionality and cleverly named it NIO which stands for "new I/O."
You will not be asked about those Java 1.4 additions on the exam.
The APIs prior to Java 7 still had a few limitations when you had to write applications that focused heavily on files and file manipulation.
Trying to write a small routine to list all the files created during the past day within a directory tree
There was no support for navigating directory trees, and just reading attributes of a file was also quite hard.
In Java 7, this whole routine is approximately 17 lines of code.
Since the Java 7 functionality was added to package names that begin with java.nio,
the new name was NIO.2.
Since NIO 2 builds upon the original I/O, some of those concepts are still
tested on the exam in addition to the new parts. Fortunately, you
will not have to become a total I/O or NIO expert to do well on the exam.
The intention of this site preparation was to include just the basic aspects of these technologies, and in this module,
we cover the essentials to get through these objectives on the exam.
Java File Object Class
Java File Class
class represents a filename on the host system.
This filename may also include an absolute
class also attempts to abstract system-dependent filename features.
For example, using the
class variable, you can get a file's path separator character.
object does not represent a file. Occasionally this distinction is crucial.
For instance, File objects
can represent directories as well as files.
Also, you cannot assume that a file exists just because you have a
object for a file.
There are three constructor methods in java.io.File
. Each takes some variation of a filename as an argument(s).