title: Eclipse plugin: create a new file
body: <p>I'm trying to create a new file in an eclipse plugin. It's not necessarily a Java file, it can be an HTML file for example.</p>
  
  <p>Right now I'm doing this:</p>
  
  <pre class="lang-java prettyprint-override"><code>IProject project = ...;
  IFile file = project.getFile("/somepath/somefilename"); // such as file.exists() == false
  String contents = "Whatever";
  InputStream source = new ByteArrayInputStream(contents.getBytes());
  file.create(source, false, null);
  </code></pre>
  
  <p>The file gets created, but the problem is that it doesn't get recognized as any type; I can't open it in any internal editor. That's until I restart Eclipse (refresh or close then open the project doesn't help). After a restart, the file is perfectly usable and opens in the correct default editor for its type.</p>
  
  <p>Is there any method I need to call to get the file outside of that "limbo" state?</p>