public static @NotNull CharSequence loadText(@NotNull VirtualFile file, int limit) {
    FileType type = file.getFileType();
    if (type.isBinary()) {
      throw new IllegalArgumentException("Attempt to load truncated text for binary file: " + file.getPresentableUrl() + ". File type: " + type.getName());
    }

    if (file instanceof LightVirtualFile) {
      return limitCharSequence(((LightVirtualFile)file).getContent(), limit);
    }

    if (file.isDirectory()) {
      throw new AssertionError("'" + file.getPresentableUrl() + "' is a directory");
    }
    try {
      byte[] bytes = limit == UNLIMITED ? file.contentsToByteArray() : VfsUtilCore.loadNBytes(file, limit);
      return getTextByBinaryPresentation(bytes, file);
    }
    catch (IOException e) {
      LOG.debug(e);
      return Strings.EMPTY_CHAR_SEQUENCE;
    }
  }
public static @NotNull CharSequence loadText(@NotNull VirtualFile file, int limit)