3 File Class and File Objects
The File class provides a key mechanism to manage files and directories. We use the File class to create File objects. When we create a File object, we associate it with a pathname (passed as argument to the constructor). The key points about the File objects are:
• A File object is associated with a pathname.
• The File object logically represents a disk file or directory specified by the pathname (at a particular point in time such a disk file or directory may or may not exist)
• The File object contains information about the denoted disk file or directory (including whether or not it exists)
• Using the File object, we can perform a number of useful operations on the denoted disk file or directory (including creating it or deleting it) In what follows we will elaborate on these methods and illustrate how they can help us perform various tasks.