title: Eclipse Plugin Get Code from Current Open File
body: <p>How can I get the code from the current open file in Eclipse returned in a <code>String</code> or <code>String[]</code>? I need this for a plugin I'm making.</p>
  
  <p>Let's say I have the following code:</p>
  
  <pre><code>public class HelloWorld {
      public static void main(String[] args) {
          System.out.println("Hello, world!");
      }
  }
  </code></pre>
  
  <p>If I have HelloWorld.java open, how do I get that code returned in a <code>String[]</code>? The <code>String[]</code> would contain:</p>
  
  <ul>
  <li>"public class HelloWorld {"</li>
  <li>"public static void main(String[] args) {"</li>
  <li>"System.out.println("Hello, world!");"</li>
  <li>"}"</li>
  <li>"}"</li>
  </ul>