O'Reilly logo

Special Edition Using Java 2 Standard Edition by Geoff Friesen, Chuck Cavaness, Brian Keeton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required