boolean (@NotNull VirtualFile virtualFile, @Nullable Charset oldCharset, @NotNull Charset newCharset) { if (!virtualFile.isDirectory() && !Comparing.equal(newCharset, oldCharset)) { Document document; byte[] bytes; try { document = FileDocumentManager.getInstance().getDocument(virtualFile); if (document == null) throw new IOException(); bytes = virtualFile.contentsToByteArray(); } catch (IOException e) { return false; } // ask whether to reload/convert when in doubt return new ChangeFileEncodingAction().chosen(document, null, virtualFile, bytes, newCharset); } return true; }