code: public static void writeScriptFile(
              InputStream stream,
              String scriptString,
              Reader reader,
              LineEndingStyle style,
              File scriptfile
      ) throws IOException
      {
  
          try (FileWriter writer = new FileWriter(scriptfile)) {
              if (null != scriptString) {
                  ScriptfileUtils.writeReader(new StringReader(scriptString), writer, style);
              } else if (null != reader) {
                  ScriptfileUtils.writeReader(reader, writer, style);
              } else if (null != stream) {
                  ScriptfileUtils.writeStream(stream, writer, style);
              } else {
                  throw new IllegalArgumentException("no script source argument");
              }
          }
      }
docs: Write script content to a destination file from one of the sources
  
  @param stream       stream source
  @param scriptString script content
  @param reader       reader source
  @param style        line ending style
  @param scriptfile   destination file
  
  @throws IOException on io error