Google for mime types. There are tables of hundreds of extensions with descriptive types and some hints about what programs might open them. This kind of thing isn't perfect ... some extensions are ambiguous and might have several meanings.
Some files have a little "signature" at the beginning, like Java class files all start with x'CAFEBABE. I don't know a good catalog of these, but there aren't many compared to the number of file types in the world and they would be easy to fake if somebody wanted to confuse you.
Is that the kind of thing you're after?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
posted 10 years ago
Yes, thank you. It looks like this is not a trivial task. Thanks again.
JavaBeans Activation Framework (JAF) is a standard extension to the Java platform that lets you take advantage of standard services to: determine the type of an arbitrary piece of data; encapsulate access to it; discover the operations available on it; and instantiate the appropriate bean to perform the operation(s).
I haven't tried it out, but you should be able to use that to detect the MIME type of a file like this: