Basic HTML version of Foils prepared Sept 21 1998

Foil 38 The File Class

From Java Tutorial 98- 4: Multi-Treading, Useful Java Classes, I/O and Networking NAVO Tutorial -- Sept 23 1998. by Geoffrey C. Fox, Nancy McCracken

File class for Foil 38
The File class defines methods and variables that provide access to the underlying file system in a machine-independent way.
For example, there are methods getParent() and getPath(), as well as boolean methods isDirectory() and isFile(), plus many more.
A very handy method is the list() method, which returns a string array of directory contents:
  • File dir = new File( "/tmp" );
  • if ( dir.exists() && dir.isDirectory() )
  • String directory[] = dir.list();
Instances of class File may be used in lieu of filename strings in InputStream constructors.



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Nov 28 1998