title: How to make a method run only once in the lifetime of application
body: <p>I have a method that fills in a file with default values and I call that method in the constructor. I want that method to run only once ( I mean by only once so when the user press the play button /in eclipse/ then that method will not run in the second press. </p>
  
  <p>I have tried something like this but it doesn't work :</p>
  
  <pre><code>private boolean defaultExecuted;
  public synchronized void defaultStatsFile()
  {
      if (defaultExecuted)
      {
          return;
      }
      else
      {
          fileReadNWrite.configWriter("panel1", "non-US incidents");
          fileReadNWrite.configWriter("panel2", "Hoaxes");
          fileReadNWrite.configWriter("panel3", "Under NUFORC investigation");
          fileReadNWrite.configWriter("panel4", "Likliest Shape");
          defaultExecuted = true;
      }
  
  }
  </code></pre>
  
  <p>Is there a smarter way to fill in a file only once ?</p>
  
  <p>Please if something is not clear comment and I will reply.
  Any help is appreciated.</p>