public static String fileToString(File f) throws Exception {
    StringBuilder sb = new StringBuilder();
    String line;
    try {
      BufferedReader in = new BufferedReader(new FileReader(f));
      while ((line = in.readLine()) != null) sb.append(line + "\n");
    } catch (Exception e) {
      throw new Exception("Error loading Backus-Naur definition file." +
                          "\tCannot load file: " + f.getName());
    }
    return sb.toString();
  }