Create java class from text? Follow
Whats the best way to create a java file and add raw text contents to it?
I noticed these two methods, but first one doesn't give a location to put the file, and the second one I'm missing context too. Am I missing some docs on this? So what are the steps to get the file into the project?
PsiFile psiFile = PsiFileFactory.getInstance(project).createFileFromText(name, StdFileTypes.JAVA, contents);
Please sign in to leave a comment.
How I did it:
PsiDirectory createdNameTokensPackageDirectories = createdNameTokensPackage.getDirectories();
PsiFile element = PsiFileFactory.getInstance(project).createFileFromText(nameFile, JavaFileType.INSTANCE, contents);
PsiElement createdNameTokensClass = createdNameTokensPackageDirectories.add(element);
I happen to come across same problem. Glad to see your post.
Could you please tell me what is "createdNameTokensPackage" in your comment above ?