示例#1
0
  private void readInBeaches() throws Exception {

    File theFile = Play.application().getFile("conf/beaches.csv");

    BufferedReader br = new BufferedReader(new java.io.FileReader(theFile));

    String sCurrentLine;
    br.readLine(); // Get rid of the header row
    try {

      while ((sCurrentLine = br.readLine()) != null) {
        String[] beachFields = sCurrentLine.split(",");

        Beach beach;
        try {
          beach = new Beach(beachFields);
        } catch (Exception e) {
          continue;
        }
        beach.save();
      }
    } catch (Exception e) {
      e.printStackTrace();
      throw e;
    } finally {
      try {
        br.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }