code: package tools;
  
  import java.io.BufferedReader;
  import java.io.FileReader;
  import java.util.ArrayList;
  
  /**
   * Created with IntelliJ IDEA.
   * User: Diego
   * Date: 04/10/13
   * Time: 16:56
   * This is a Java port from Tom Schaul's VGDL - https://github.com/schaul/py-vgdl
   */
  public class IO
  {
      /**
       * Default constructor
       */
      public IO(){}
  
      /**
       * Reads a file and returns its content as a String[]
       * @param filename file to read
       * @return file content as String[], one line per element
       */
      public String[] readFile(String filename)
      {
          ArrayList<String> lines = new ArrayList<String>();
          try{
              BufferedReader in = new BufferedReader(new FileReader(filename));
              String line = null;
              while ((line = in.readLine()) != null) {
                  lines.add(line);
              }
              in.close();
          }catch(Exception e)
          {
              System.out.println("Error reading the file " + filename + ": " + e.toString());
              e.printStackTrace();
              return null;
          }
          return lines.toArray(new String[lines.size()]);
      }
  }
  