IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("MyProject"); project.create(null); project.open(null);
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("MyProject"); IFolder folder = project.getFolder("src"); IFile file = folder.getFile("myfile.txt"); byte[] content = "Hello world!".getBytes(); file.create(new ByteArrayInputStream(content), true, null);This code creates a new file named "myfile.txt" in the "src" folder of the "MyProject" project and adds the text "Hello world!" to its contents. Package library: org.eclipse.core.resources.