On Thu, 10 Feb 2005 12:00:25 +0100, "Erik Bruchez" <ebruchez@orbe...>
> Eric van der Vlist wrote:
> > 1. That would be nice if the URL generator could rely on the media
> > type given by the OS for local files. For instance, if I read
> > a .swx file and that my OS is configured correctly, the URL
> > generator could guess that the media type is
> > "application/vnd.sun.xml.writer".
> Is there a standard mechanism in Java to get the media type of a file
> from the OS? With URLConnection, you can get information based on the
> content-type header if there is one, or based on content (fairly poorly
> implemented in the JDK last time I checked).
Not in JDK 1.4. Haven't looked in JDK 1.5.
In any case implementing it is a total mess. For example on
Linux I can specify the type associated with a file extension
o KDE's desktop settings
o GNOME desktop settings
o XPDE desktop settings
So what gets used will depend how I log in.
And wrt /etc/magic, it isn't standard. That is that while it's
described in POSIX.2 it, in practice the format of the file,
the command lines to work with it, and the output from the tools
that do work with it, all vary from *NIX platform to platform.
So getting the type from the OS when writing Java isn't a
On the other hand, perhaps there something that can be done
the browser user's expectation wrt to file type then perhaps