Package javax.activation

Examples of javax.activation.FileTypeMap


     * Return the content-type the would be returned for this file name.
     */
    public String getContentTypeFor(String fileName) {
 
        // everything else
        FileTypeMap typeMap = FileTypeMap.getDefaultFileTypeMap();
        return typeMap.getContentType(fileName);
    }
View Full Code Here


    private InputStream inputStream = null;
    private Date lastModified = null;

    public AtomMediaResource(ThemeResource resource) throws FileNotFoundException {
        // TODO: figure out why PNG is missing from Java MIME types
        FileTypeMap map = FileTypeMap.getDefaultFileTypeMap();
        if (map instanceof MimetypesFileTypeMap) {
            try {
                ((MimetypesFileTypeMap) map).addMimeTypes("image/png png PNG");
            } catch (Exception ignored) {
            }
        }
        contentType = map.getContentType(resource.getName());
        contentLength = (int)resource.getLength();
        lastModified = new Date(resource.getLastModified());
        inputStream = resource.getInputStream();
    }
View Full Code Here

                atomURL+"/"+ website.getHandle()
                + "/resource/" + filePath;
        URLStrategy urlStrategy = WebloggerFactory.getWeblogger().getUrlStrategy();
        String viewURI = urlStrategy.getWeblogResourceURL(website, filePath, true);
       
        FileTypeMap map = FileTypeMap.getDefaultFileTypeMap();
        // TODO: figure out why PNG is missing from Java MIME types
        if (map instanceof MimetypesFileTypeMap) {
            try {
                ((MimetypesFileTypeMap)map).addMimeTypes("image/png png PNG");
            } catch (Exception ignored) {}
        }
        String contentType = map.getContentType(file.getName());
       
        Entry entry = new Entry();
        entry.setId(editMediaURI);
        entry.setTitle(file.getName());
        entry.setUpdated(new Date(file.getLastModified()));
View Full Code Here

      byte[] buf = new byte[response.getBufferSize()];
      InputStream in = null;
      try {

        final File file = new File(root.concat("/").concat(name));
        final FileTypeMap ftm = new MimetypesFileTypeMap();

        response.setContentType(ftm.getContentType(file));

        // Para abrir o vizualizador do tipo do arquivo
        response.setHeader("Content-Disposition", "filename=" + name);

        response.setContentLength((int) file.length());
View Full Code Here

    sender.setUsername("username");
    sender.setPassword("password");

    MimeMessageHelper message = new MimeMessageHelper(sender.createMimeMessage(), "UTF-8");
    assertEquals("UTF-8", message.getEncoding());
    FileTypeMap fileTypeMap = new ConfigurableMimeFileTypeMap();
    message.setFileTypeMap(fileTypeMap);
    assertEquals(fileTypeMap, message.getFileTypeMap());

    message.setTo("you@mail.org");
    sender.send(message.getMimeMessage());
View Full Code Here

    sender.setHost("host");
    sender.setUsername("username");
    sender.setPassword("password");
    sender.setDefaultEncoding("UTF-8");

    FileTypeMap fileTypeMap = new ConfigurableMimeFileTypeMap();
    sender.setDefaultFileTypeMap(fileTypeMap);
    MimeMessageHelper message = new MimeMessageHelper(sender.createMimeMessage());
    assertEquals("UTF-8", message.getEncoding());
    assertEquals(fileTypeMap, message.getFileTypeMap());
View Full Code Here

                + "/app/" + website.getHandle()
                + "/resource/" + file.getName();
        String viewURI = absUrl
                + "/resources/" + website.getHandle()
                + "/" + file.getName();
        FileTypeMap map = FileTypeMap.getDefaultFileTypeMap();
        String contentType = map.getContentType(file);

        Entry entry = new Entry();
        entry.setTitle(file.getName());
        entry.setUpdated(new Date(file.lastModified()));
View Full Code Here

      }
      String lowerName = fileName.toLowerCase();
      if (lowerName.endsWith(".json")) {
        return "application/json";
      }
      FileTypeMap typeMap = FileTypeMap.getDefaultFileTypeMap();
      String ret = typeMap.getContentType(fileName);
      if (ret != null) {
        return ret;
      }
      ret = URLConnection.guessContentTypeFromName(fileName);
      if (ret != null) {
View Full Code Here

   * or a default ConfigurableMimeFileTypeMap if none found for the message
   * @see ConfigurableMimeFileTypeMap
   */
  protected FileTypeMap getDefaultFileTypeMap(MimeMessage mimeMessage) {
    if (mimeMessage instanceof SmartMimeMessage) {
      FileTypeMap fileTypeMap = ((SmartMimeMessage) mimeMessage).getDefaultFileTypeMap();
      if (fileTypeMap != null) {
        return fileTypeMap;
      }
    }
    ConfigurableMimeFileTypeMap fileTypeMap = new ConfigurableMimeFileTypeMap();
    fileTypeMap.afterPropertiesSet();
    return fileTypeMap;
  }
View Full Code Here

        return m.replaceAll(replacement);
    }

    public static String getContentTypeFromFileName(String fileName) {

        FileTypeMap map = FileTypeMap.getDefaultFileTypeMap();
       
        // TODO: figure out why PNG is missing from Java MIME types
        if (map instanceof MimetypesFileTypeMap) {
            try {
                ((MimetypesFileTypeMap)map).addMimeTypes("image/png png PNG");
            } catch (Exception ignored) {}
        }

        return map.getContentType(fileName);
    }
View Full Code Here

TOP

Related Classes of javax.activation.FileTypeMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.