User Tools

Site Tools


java:mimetypes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

java:mimetypes [2014/12/24 10:42] (current)
Line 1: Line 1:
 +====== Cómo conocer el mimetype de un fichero =====
 +
 +De esta página tan interesante -> [[http://​www.rgagnon.com/​javadetails/​java-0487.html]] he encontrado la manera de obtener el [[wp>​mimetype]] de un fichero dado. Aquí va el código de ejemplo: ​
 +
 +<code java>
 +import javax.activation.MimetypesFileTypeMap;​
 +import java.io.File;​
 +
 +class GetMimeType {
 +  public static void main(String args[]) {
 +    File f = new File("​gumby.gif"​);​
 +    System.out.println("​Mime Type of " + f.getName() + " is " +
 +                         new MimetypesFileTypeMap().getContentType(f));​
 +    // expected output :
 +    // "Mime Type of gumby.gif is image/​gif"​
 +  }
 +}
 +</​code>​
 +
 +Dice en la página: ​
 +
 +>The MimetypesFileTypeMap looks in various places in the user's system for MIME types file entries. When requests are made to search for MIME types in the MimetypesFileTypeMap,​ it searches MIME types files in the following order:
 +>
 +>  - Programmatically added entries to the MimetypesFileTypeMap instance.
 +>  - The file .mime.types in the user's home directory.
 +>  - The file <​java.home>/​lib/​mime.types.
 +>  - The file or resources named META-INF/​mime.types.
 +>  - The file or resource named META-INF/​mimetypes.default (usually found only in the activation.jar file). ​
 +
  
java/mimetypes.txt · Last modified: 2014/12/24 10:42 (external edit)