Docsity

Accessing Files and Directories using Java's File Class, Slides of Object Oriented Programming

Partial preview of the text

Download Accessing Files and Directories using Java's File Class and more Slides Object Oriented Programming in PDF only on Docsity!

1

Chapter 9: Accessing Files and

Directories

2

Basics of the File Class

  • A object of type File encapsulates a reference to what may be a physical file or directory NOT the file itself
  • How to use the file Class. File myFile = new File(“path”);
  • You can use the above statement to refer to a directory
  • The constructor also accepts a URL object
  • File.separator is a constant that enables you to write platform independent code.
  • File class methods (check documentation)
  • Ex: TryFile.java, TryFile2.java