{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-guides/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Mime Types","description":"Accelerate E&P application development and protect your innovation by consuming our Data and Domain APIs / Platform APIs.","lang":"en-US","meta":[{"name":"robots","content":"noindex"}],"llmstxt":{"hide":false}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"mime-types","__idx":0},"children":["Mime Types"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"mime-type-extension","__idx":1},"children":["Mime Type Extension"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This document describes how to recognize different file types we use."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"introduction","__idx":2},"children":["Introduction"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Originally, Multipurpose Internet Mail Extensions (MIME) was invented to attach binary data to e-mail. MIME's use, however, has grown beyond describing the content of e-mail to describing content type in general. Basically, this is just a way to categorize file types. File type consists of a type and subtype, for example ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["image/jpg"]},". Here image is type and jpg is subtype. Which means image files in ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["jpeg"]}," format. You can give any name to any file type. But, of course, meaningful names are preferable. In our domain we have ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["seismic/x-segy"]},", ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["horizon/x-xhz"]}," and so on. Which means seismic data is in SEG-Y format, horizon data in xhz (xml actually) format. Prefix x- means this type is not standard. This is just a convention. The Internet Assigned Numbers Authority (IANA) has directory of all MIME types. You can find ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["image/jpg"]}," there, but there is no ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["seismic/segy"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"mime-type-resolvers","__idx":3},"children":["MIME type resolvers"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The NetBeans platform has mechanism to resolve (map file to literal string) MIME type. This is abstract class MIMEResolver. Everyone who wants to add new resolver should extend this abstract class and override one method:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["FINDMIMETYPE"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["public String findMIMEType(FileObject fo);"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To let NetBeans know about this resolver you have to put the class name into META-INF/services/org.openide.filesystems.MIMEResolver file. Every time NetBeans should recognize file type it passes FileObject to all resolvers until it finds one which returns not null. NetBeans has powerful generic resolver which is used in most cases. Unfortunately, it doesn't allow to change file extension mapping on the fly. In other words, user can not change rules how to recognize files. So, new MIME resolver was introduced:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["DYNAMICMIMERESOLVER"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"public class DynamicMimeResolver extends MIMEResolver {\n    @Override\n    public String findMIMEType(FileObject fo) {\n        String ext = fo.getExt();\n        if (ext.length()>0) {\n            return MimeRepository.getDefault().getMime(ext);\n        } else {\n            if (!fo.isFolder() && fo.getName().endsWith(\"CIND\")) \n                return \"seismic/promax\";\n            return null;\n        }\n    }\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["It has one hard coded MIME type. Rest of mapping is coming from MimeRepository class which reads ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["layer.xml"]}," file and keeps all data in memory. ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Layer.xml"]}," has configuration data describing all types. This is a small fragment:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["MIMEREPOSITORY"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"xml","header":{"controls":{"copy":{}}},"source":"<folder name = \"MimeTypes\">\n    <folder name =\"seismic\">\n        <folder name =\"x-segy\">\n            <attr name=\"name\" stringvalue = \"Segy\"/>\n            <attr name=\"ext\" stringvalue = \"segy sgy y\"/>\n        </folder>\n        <folder name =\"x-tseismic\">\n            <attr name=\"name\" stringvalue = \"Transposed-Seismic\"/>\n            <attr name=\"ext\" stringvalue = \"xts\"/>\n        </folder>\n    </folder>\n</folder>\n","lang":"xml"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["As you can see attribute name gives human readable name for this type, attribute ext gives extension list. This ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["layer.xml"]}," file is located inside jar and is read-only. NetBeans has a nice feature, which allows to \"override\" this file. All changes are stored in working directory, but logically everything looks like you changed the layer.xml file. So, you can think about values in ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["layer.xml"]}," as default values. When you make fresh installation ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["layer.xml"]}," defines all mapping rules. Then you can modify them."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Right now there isn't any GUI to do that, just API. Class DataUtil has a static method:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["DATAUTIL - SETEXTENSIONS"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"/**\n* Set extensions for some mime type. All changes are stored in working directory.\n* @param mime type\n* @param exts array of extensions to set\n* @throws IOException\n*/\npublic static void setExtensions(String mime, String[] exts) throws IOException{\n    MimeRepository.getDefault().setExtensions(mime, exts);\n}\nAlso it has several more methods related to mime types: \n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DATAUTIL - MIME TYPES METHODS"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"/**\n* Returns all registered MIME types for data type. For example,\n* horizon data may have several mime types- horizon/x-xhz, horizon/x-ascii, ...\n* @param dataType data type name.\n* @return Array of MIME types.\n*/\npublic static String[] getMimeTypes(String dataType){...}\n/**\n* Returns human readable description (Segy files, for example)\n* @param mime MIME type\n* @return return Returns human readable description\n*/\npublic static String getMimeDescription(String mime){...}\n/**\n* Return all registered file extensions.\n* @param mime MIME type\n* @return array of file extensions.\n*/\npublic static String[] getExtensions(String mime){...}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["These methods are supposed to be used when you create File Chooser, for example. Besides file chooser mime types are used to associate icons, actions, data loaders, pop up menus."]}]},"headings":[{"value":"Mime Types","id":"mime-types","depth":1},{"value":"Mime Type Extension","id":"mime-type-extension","depth":2},{"value":"Introduction","id":"introduction","depth":3},{"value":"MIME type resolvers","id":"mime-type-resolvers","depth":3}],"frontmatter":{"title":"Mime Types","pageId":"other-useful-intviewer-apis/mime-types","seo":{"title":"Mime Types"}},"lastModified":"2026-10-22T14:32:05.579Z","pagePropGetterError":{"message":"","name":""}},"slug":"/solutions/intviewer/other-useful-intviewer-apis/mime-types","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}