You've learned how to read and write data in files using file input streams, file output streams, and file channels, but that's not all there is to files. Files can be created, moved, renamed, copied, deleted, and otherwise manipulated without respect to their contents. Files are also often associated with metainformation that's not strictly part of the contents of the file, such as the time the file was created, the icon for the file, the permissions that determine which users can read or write to the file, and the name of the file.
While the view of the contents of a file as an ordered sequence of bytes used by file input and output streams is almost standard across platforms, the metainformation is not. The java.io.File class attempts to provide a platform-independent abstraction for common file operations and metainformation. Unfortunately, this class really shows its Unix roots. It works well on Unix, but at best adequately on Windows and the Macintosh (even Mac OS X). Coming up with something that genuinely works on all platforms is an extremely difficult problem.
File manipulation is thus one of the real difficulties of cross-platform Java programming. Before you can hope to write truly cross-platform code, you need a solid understanding of the filesystem basics on all the target platforms. This chapter tries to cover those basics for the major platforms that support Java: Unix/Linux, Windows/DOS, and the Mac. It then shows you how to write your file code so that it's as portable as possible.
Basic I/O
Introducing I/O
Output Streams
Input Streams
Data Sources
File Streams
Network Streams
Filter Streams
Filter Streams
Print Streams
Data Streams
Streams in Memory
Compressing Streams
JAR Archives
Cryptographic Streams
Object Serialization
New I/O
Buffers
Channels
Nonblocking I/O
The File System
Working with Files
File Dialogs and Choosers
Text
Character Sets and Unicode
Readers and Writers
Formatted I/O with java.text
Devices
The Java Communications API
USB
The J2ME Generic Connection Framework
Bluetooth
Character Sets