File Dialogs  «Prev 


Mac File Types in Java

Filename extensions are an unreliable means of determining the type of a file. Users can easily change them, and it's hard to distinguish between files that belong to different applications that have the same type. Many users have complained once they have discovered that the installation of some new Microsoft software such as Internet Explorer now makes all their HTML files appear to belong to Explorer instead of Netscape.
The Macintosh solved this problem over a decade ago. Almost every Mac file has a four-letter type code like TEXT and a four-letter creator code like R*ch.
Since each file has both a type code and a creator code, you can distinguish between files of the same type that belong to different applications. Installing Internet Explorer does not mean that Internet Explorer suddenly thinks it owns all your Firefox and Chrome documents, as is the case when you install Internet Explorer on Windows.
Software vendors register codes with Apple so companies do not accidentally violate another companies software rights.
Since codes are almost never seen by end users, there's not a huge rush to snap up all the good ones like TEXT and HTML. On an individual user's Macintosh, the list of codes that particular Macintosh understands is stored in the Desktop database, a file the users never see, and only rarely have to worry about.
Overall, this is a great system that's worked incredibly well for more than a decade. Neither Windows nor Unix has anything close to as simple and as trouble-free. Because Windows and Unix have not adopted Mac-style type and creator codes, Java does not have any standard means for accessing them.

Java I/O
Macintosh files are a little different. Mac files are divided into two forks, each of which is equivalent to a separate file on other platforms. The first part of a Mac file is called the data fork and contains the text, image data, or other basic information of the file. The second part of the file is called the resource fork and typically contains localizable strings, pictures, icons, graphical user interface components like menubars and dialogs, executable code, and more. On a Macintosh, all the standard java.io classes work exclusively with the data fork.