Ejemplo n.º 1
0
  private String ReadWholeFileToString(String filename) {

    File file = new File(filename);
    StringBuffer contents = new StringBuffer();
    BufferedReader reader = null;

    try {
      reader = new BufferedReader(new FileReader(file));
      String text = null;

      // repeat until all lines is read
      while ((text = reader.readLine()) != null) {
        contents.append(text).append(System.getProperty("line.separator"));
      }
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      try {
        if (reader != null) {
          reader.close();
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

    // show file contents here
    return contents.toString();
  }
Ejemplo n.º 2
0
 private void ExitBtnMouseClicked(
     java.awt.event.MouseEvent evt) { // GEN-FIRST:event_ExitBtnMouseClicked
   // TODO add your handling code here:
   System.exit(0);
 } // GEN-LAST:event_ExitBtnMouseClicked