Basic HTML version of Foils prepared 17 Nov 97

Foil 39 The File Class

From Java Tutorial, July 1, 1996 CEWES Tutorial, CPS606, JSU Class CSC499 -- July 22-25 1997, Fall 97. by Nancy J. McCracken,Geoffrey C. Fox, Tom Scavo

File class for Foil 39
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 Wed Apr 1 1998