title: Write an executable .sh file with Java for OSX
body: <p>So I am trying to write an .sh file that will be executable, this is how I'm currently writing it:</p>
  
  <pre><code>Writer output = null;
  
  try {
    output = new BufferedWriter(new FileWriter(file2));
    output.write(shellScriptContent);
    output.close();
  } catch (IOException ex) {
    Logger.getLogger(PunchGUI.class.getName()).log(Level.SEVERE, null, ex);
  }
  </code></pre>
  
  <p>So that writes the file just fine, but it is not executable.  Is there a way to change the executable status when I write it?</p>
  
  <p>Edit: To further clarify, I am trying to make it execute by default, so that for instance, if you double clicked the generated file, it would automatically execute.</p>