本文整理汇总了Java中eu.medsea.mimeutil.detector.MagicMimeMimeDetector类的典型用法代码示例。如果您正苦于以下问题:Java MagicMimeMimeDetector类的具体用法?Java MagicMimeMimeDetector怎么用?Java MagicMimeMimeDetector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MagicMimeMimeDetector类属于eu.medsea.mimeutil.detector包,在下文中一共展示了MagicMimeMimeDetector类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: provideMimeUtil2
import eu.medsea.mimeutil.detector.MagicMimeMimeDetector; //导入依赖的package包/类
@Provides
@Singleton
MimeUtil2 provideMimeUtil2() {
MimeUtil2 m = new MimeUtil2();
m.registerMimeDetector(ExtensionMimeDetector.class.getName());
m.registerMimeDetector(MagicMimeMimeDetector.class.getName());
if (HostPlatform.isWin32()) {
m.registerMimeDetector("eu.medsea.mimeutil.detector.WindowsRegistryMimeDetector");
}
m.registerMimeDetector(DefaultFileExtensionRegistry.class.getName());
return m;
}
示例2: mimeTypeGet2
import eu.medsea.mimeutil.detector.MagicMimeMimeDetector; //导入依赖的package包/类
public static String mimeTypeGet2(Context context, String filename) {
AppState.logX(TAG, String.format("mimeTypeGet2: filename = %s", filename));
MimeType mimeType = UNKNOWN_MIME_TYPE;
AppState.logX(TAG, "mimeTypeGet2: 1");
File file = new File(filename);
AppState.logX(TAG, "mimeTypeGet2: 2");
if (file.isDirectory()) {
AppState.logX(TAG, "mimeTypeGet2: 3");
mimeType = MimeUtil2.DIRECTORY_MIME_TYPE;
AppState.logX(TAG, "mimeTypeGet2: 4");
} else {
AppState.logX(TAG, "mimeTypeGet2: 5");
MagicMimeMimeDetector detector = new MagicMimeMimeDetector(context);
AppState.logX(TAG, "mimeTypeGet2: 6");
Collection<MimeType> mimeTypes = new ArrayList<MimeType>();
AppState.logX(TAG, "mimeTypeGet2: 7");
mimeTypes.addAll(detector.getMimeTypesFileName(filename));
AppState.logX(TAG, String.format("mimeTypeGet2: 8: mimeType.size = %d", mimeTypes.size()));
mimeTypes.remove(UNKNOWN_MIME_TYPE);
AppState.logX(TAG, "mimeTypeGet2: 9");
mimeType = MimeUtil2.getMostSpecificMimeType(mimeTypes);
AppState.logX(TAG, "mimeTypeGet2: 10");
}
AppState.logX(TAG, String.format("mimeTypeGet2: mimeType = %s", mimeType != null ? mimeType.toString() :
"null"));
return mimeType != null ? mimeType.toString() : context.getString(R.string.mime_file_text);
}
示例3: getMimeType
import eu.medsea.mimeutil.detector.MagicMimeMimeDetector; //导入依赖的package包/类
private static String getMimeType(byte[] data) {
return getFirstMimeType(new MagicMimeMimeDetector().getMimeTypes(data));
}