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

in Table To:


© 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