Chapter    2

File

Applications often interact with a file system, which is usually implemented as a hierarchy of files and directories starting from a root directory. Operating systems on which a Java virtual machine (JVM) runs typically support at least one file system. For example, Unix/Linux combines all mounted (attached and prepared) disks into one virtual file system. In contrast, Windows associates a separate file system with each active disk drive. Java offers access to the underlying operating system’s available file system(s) via its concrete java.io.File class, which this chapter explores.

Constructing File Instances

An instance of the File class contains an abstract representation of a file or directory path (a compact map that locates ...

Get Java I/O, NIO and NIO.2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.