while ( true ) { data = instr.readUnsignedByte() ; outstr.writeByte( data ) ; }
Just three statements. But those statements are buried in 60 lines of code! This is often the case in programs, where a "tight little loop" does all the work, but the set-up takes many more lines.
File
Here is brief documentation for some useful methods in File
.
There are many more useful methods. If there is something file related you wish to do, check the complete documentation.
Methods of the File Class | |
---|---|
boolean canRead() |
Returns true if the file exists and can be read; otherwise returns false. |
boolean canWrite() |
Returns true if the file exists and can be written; otherwise returns false. |
boolean delete() |
Deletes the file or directory. Returns true on success; otherwise returns false. |
boolean exists() |
Returns true if the file exists; otherwise returns false. |
String getName() | Returns the file name or directory name. |
String getPath() | Returns the path name. |
boolean isDirectory() |
Returns true for an existing directory; otherwise returns false. |
boolean isFile() |
Returns true for an existing file; otherwise returns false. |
long length() | Returns the length of a file. |
String[] list() |
Returns an array which lists the files and directories in the directory. If the File is not a directory or there is an I/O error, null is returned. |
boolean mkdir() |
Creates the directory named in this File object. Returns true if successful, otherwise, false. |
(Brain teaser: ) Is it possible for isDirectory()
and isFile()
both to
return false?