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.
|