java - Adding file types to be recognized by Files.probeContentType(new File(".ttf").toPath()); -


java has build in content types detector, however, misses filetypes naturally.

files.probecontenttype(new file(".ttf").topath()); 

it appears if implementation allows 1 add more filetypedetectors cannot figure out how.

reference:

http://docs.oracle.com/javase/7/docs/api/java/nio/file/files.html#probecontenttype(java.nio.file.path)

http://docs.oracle.com/javase/7/docs/api/java/nio/file/spi/filetypedetector.html

so how can 1 add more files probed?

on note, consider javas file.provecontenttype effecient? not 1 whas create path object, seems iterate on these each time. guess caching mechanism required on top.

to install own filetypedetector first create own implementation:

public class myfiletypedetector extends java.nio.file.spi.filetypedetector {     public string probecontenttype(path path) throws ioexception {         return ...     } } 

then second add file /meta-inf/services/java.nio.file.spi.filetypedetector jar contains implementation: content qualified class name of implementation:

org.example.myfiletypedetector  

Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -