title: Javascript Nashorn scripting mode: how to write to file
body: <p>I'm writing a shell script to be run with jjs -scripting under Java 8. However, a key requirement is that I need to be able to write to a number of files. (So I can't just print() to stdout and redirect.) </p>
  
  <p>There's handily readFully to read a file, but I don't see any writeFully, which seems odd to me.</p>
  
  <p>I thought probably I could just $EXEC an echo command, but I can't get that to work:</p>
  
  <pre><code>jjs&gt; x='some string'
  some string
  jjs&gt; $EXEC("echo '"+x+"' &gt;test.out");
  some string &gt;test.out
  </code></pre>
  
  <p>So my next thought is that I have to load up and call the appropriate Java classes, but that seems like it's over-complicating a simple function. What am I missing?</p>