On Thu, 10 Feb 2005 12:00:25 +0100, "Erik Bruchez" <[EMAIL PROTECTED]> said: > 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 via o /etc/magic o KDE's desktop settings o GNOME desktop settings o XPDE desktop settings o .... 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 good proposition. On the other hand, perhaps there something that can be done in JavaScript. That is if what one wants to do is meet the browser user's expectation wrt to file type then perhaps JavaScript could be used to achieve this.... -- Regards, Dan S ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ orbeon-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/orbeon-user
