Creating Files

If you need to obtain information about a file, you should create an object of Java's File class. This class enables you to query the system about everything from the file's name to the time it was last modified. You can also use the File class to make new directories, as well as to delete and rename files. Create a File object by calling one of the class's three constructors, whose signatures are as follows:

File(String path)
File(String path, String name)
File(File dir, String name)

The first constructor creates a File object from the given full pathname (for example, C:\CLASSES\MYAPP.JAVA). The second constructor creates the object from a separate path and a file. The third creates the object from a separate path and ...

Get Special Edition Using Java 2 Standard Edition 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.