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

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -