IsFileBinary() Follow
Answered
How to detect that file is binary i.e. IDE doesn't support undo with this file. Maybe exists something like list of supported file extensions?
Please sign in to leave a comment.
>How to detect that file is binary
VirtualFile.getFileType().isBinary()
>Maybe exists something like list of supported file extensions?
Yes, you can find it in "File | Settings | Editor | File Types".
This is backed by different `com.intellij.openapi.fileTypes.FileType` implementations. (you can register your own file type in a plugin with `com.intellij.openapi.fileTypes.FileTypeFactory`)
Files can also be auto detected as text files, if they are in ASCII / UTF-8 / has BOM.
There are some pitfalls though:
`com.intellij.openapi.fileEditor.FileDocumentManager#getDocument` can return (read only) Document for binary file, if it can be decompiled.
Also, for very big files it can return "preview" Document with only the beginning of content.
See `com.intellij.openapi.fileEditor.FileDocumentManager#isPartialPreviewOfALargeFile`.