protected String getMimeTypeByContent() throws IOException { IContentAdapter content = fResource.getAdapter(IContentAdapter.class); InputStream input = content.getContentInput(); try { if (!input.markSupported()) { input = new BufferedInputStream(input); } String mimeType = fDetector.getMimeType(input); if (mimeType != null) { int idx = mimeType.lastIndexOf(';'); if (idx > 0) { mimeType = mimeType.substring(0, idx); } } return mimeType; } finally { input.close(); } }