FileType (@Nullable String preferredName) { if (preferredName != null) { int extOffset = preferredName.lastIndexOf("."); if (extOffset >= 0 && preferredName.length() > extOffset + 1) { String extension = preferredName.substring(extOffset + 1); FileType fileType = FileTypeManager.getInstance().getFileTypeByExtension(extension); if (!(fileType instanceof UnknownFileType || fileType.isBinary())) { return fileType; } } } return PlainTextFileType.INSTANCE; }