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
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:
  • File dir = new File( "/tmp" );
  • if ( dir.exists() && dir.isDirectory() )
  • String directory[] = dir.list();
4 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 Sat Nov 28 1998