Java Code Examples for javax.activation.FileTypeMap#getDefaultFileTypeMap()
The following examples show how to use
javax.activation.FileTypeMap#getDefaultFileTypeMap() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MockServletContextTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Introduced to dispel claims in a thread on Stack Overflow: * <a href="http://stackoverflow.com/questions/22986109/testing-spring-managed-servlet">Testing Spring managed servlet</a> */ @Test public void getMimeTypeWithCustomConfiguredType() { FileTypeMap defaultFileTypeMap = FileTypeMap.getDefaultFileTypeMap(); assertThat(defaultFileTypeMap, instanceOf(MimetypesFileTypeMap.class)); MimetypesFileTypeMap mimetypesFileTypeMap = (MimetypesFileTypeMap) defaultFileTypeMap; mimetypesFileTypeMap.addMimeTypes("text/enigma enigma"); assertEquals("text/enigma", sc.getMimeType("filename.enigma")); }
Example 2
Source File: FileBasedCollection.java From rome with Apache License 2.0 | 5 votes |
private void updateMediaEntryAppLinks(final Entry entry, final String fileName, final boolean singleEntry) { // TODO: figure out why PNG is missing from Java MIME types final FileTypeMap map = FileTypeMap.getDefaultFileTypeMap(); if (map instanceof MimetypesFileTypeMap) { try { ((MimetypesFileTypeMap) map).addMimeTypes("image/png png PNG"); } catch (final Exception ignored) { } } entry.setId(getEntryMediaViewURI(fileName)); entry.setTitle(fileName); entry.setUpdated(new Date()); final List<Link> otherlinks = new ArrayList<Link>(); entry.setOtherLinks(otherlinks); final Link editlink = new Link(); editlink.setRel("edit"); editlink.setHref(getEntryEditURI(fileName, relativeURIs, singleEntry)); otherlinks.add(editlink); final Link editMedialink = new Link(); editMedialink.setRel("edit-media"); editMedialink.setHref(getEntryMediaEditURI(fileName, relativeURIs, singleEntry)); otherlinks.add(editMedialink); final Content content = entry.getContents().get(0); content.setSrc(getEntryMediaViewURI(fileName)); final List<Content> contents = new ArrayList<Content>(); contents.add(content); entry.setContents(contents); }
Example 3
Source File: UnzipServlet.java From packagedrone with Eclipse Public License 1.0 | 4 votes |
@Override public void init () throws ServletException { super.init (); this.fileTypeMap = FileTypeMap.getDefaultFileTypeMap (); }