System.out.println("Mean = "
+ (fl oat)total/count);
Note that there is no structure imposed upon a fi le by Java. It is the programmer's
responsibility to impose any required logical structuring upon the fi le. 'Records' on
the fi le are not physical units determined by Java or the operating system, but logical
units set up and maintained by the programmer. For example, if a fi le is to hold
details of customer accounts, each logical record may comprise the following:
It is the programmer's responsibility to ensure that each logical record on the fi le
holds exactly these three fi elds and that they occur in the order specifi ed.
Class File has a large number of methods, the most important of which are shown below.
Returns true if fi le is readable and false otherwise.
boolean canWrite( )
Returns true if fi le is writeable and false otherwise.
Deletes fi le and returns true/false for success/failure.
Returns true if fi le exists and false otherwise.
Returns name of fi le.
Returns true if object is a directory/folder and false otherwise.
(Note that File objects can refer to ordinary fi les or to directories.)
Returns true if object is a fi le and false otherwise.
Returns length of fi le in bytes.
If object is a directory, array holding names of fi les within directory is returned.