<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -147,6 +147,26 @@ public class IoHelper
     {
         FileOutputStream out = new FileOutputStream(outFile);
         FileInputStream in = new FileInputStream(inFile);
+        copyStream(in, out, vs, type);
+        if (permissions != null &amp;&amp; IoHelper.supported(&quot;chmod&quot;))
+        {
+            chmod(outFile.getAbsolutePath(), permissions);
+        }
+    }
+
+    /**
+     * Copies an input stream to an output stream.  Both streams must already
+     * be open. If the VariableSubstitutor is not null, a substition
+     * will be done during copy.
+     *
+     * @param in          stream object for input
+     * @param out         stream object for output
+     * @param vs          substitutor which is used during copying
+     * @param type        file type for the substitutor
+     * @throws IOException if an I/O error occurs
+     */
+    public static void copyStream(InputStream in, OutputStream out, VariableSubstitutor vs, String type) throws IOException
+    {
         if (vs == null)
         {
             byte[] buffer = new byte[5120];
@@ -168,10 +188,6 @@ public class IoHelper
             bin.close();
             bout.close();
         }
-        if (permissions != null &amp;&amp; IoHelper.supported(&quot;chmod&quot;))
-        {
-            chmod(outFile.getAbsolutePath(), permissions);
-        }
     }
 
     /**
@@ -190,6 +206,26 @@ public class IoHelper
     }
 
     /**
+     * Creates a temp file with delete on exit rule. The contents of the input stream will be copied into
+     * the temporary file. If the variable substitutor is not null, variables will be replaced
+     * during copying.
+     *
+     * @param is               input stream to copy from
+     * @param ext              file extension
+     * @param vss              substitutor which is used during copying
+     * @return newly created and filled temporary file
+     * @throws IOException
+     */
+    public static File copyToTempFile(InputStream is, String ext,
+                                      VariableSubstitutor vss) throws IOException
+    {
+        File tmpFile = File.createTempFile(&quot;izpack_io&quot;, ext);
+        tmpFile.deleteOnExit();
+        IoHelper.copyStream(is, new FileOutputStream(tmpFile), vss, null);
+        return tmpFile;
+    }
+
+    /**
      * Creates a temp file with delete on exit rule. The extension is extracted from the template if
      * possible, else the default extension is used. The contents of template will be copied into
      * the temporary file. If the variable substitutor is not null, variables will be replaced</diff>
      <filename>src/lib/com/izforge/izpack/util/IoHelper.java</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c23a7a3a9ccdfbfa41c8e5a9c76136136de230d2</id>
    </parent>
  </parents>
  <author>
    <name>bbergquist</name>
    <email>bbergquist@7d736ef5-cfd4-0310-9c9a-b52d5c14b761</email>
  </author>
  <url>http://github.com/jponge/izpack/commit/bbf5a294a6db3ce08eb8afcdbd4c305a01790f21</url>
  <id>bbf5a294a6db3ce08eb8afcdbd4c305a01790f21</id>
  <committed-date>2009-06-15T16:16:23-07:00</committed-date>
  <authored-date>2009-06-15T16:16:23-07:00</authored-date>
  <message>Issue: IZPACK-158
--
Refactored the copying of one stream to another into its own method and then added a new
copyToTempFile method.  This is used to copy the internal build script to a temp file.

git-svn-id: https://svn.codehaus.org/izpack/izpack-src/trunk@2798 7d736ef5-cfd4-0310-9c9a-b52d5c14b761</message>
  <tree>ae2d91bec7367fe50f8790d6810e82c1ee1b8727</tree>
  <committer>
    <name>bbergquist</name>
    <email>bbergquist@7d736ef5-cfd4-0310-9c9a-b52d5c14b761</email>
  </committer>
</commit>
