File class

Objective

  • Use the File class in Java

The File class

  • The File class is used to find out details about a file or directory.
  • Although it can be used to create a file, the name of the class is somewhat misleading - it is more like a DirectoryEntry than a File.
  • Need to use: import java.io.File;
  • See the documentation for the File class.
  • See the FileInfo.java demonstration program (included below):

Example program