title: TransformerException: Premature end of file error
body: <p>I am trying to generate outFile base on the marshalled xml and xslt and some issue.</p>
  
  <p>Piece of code produces xml stream from object.</p>
  
  <pre><code> JAXBContext jaxbContext = JAXBContext.newInstance(EmployeeFormat.class);
   ByteArrayOutputStream os = new ByteArrayOutputStream();
   Marshaller marshaller = jaxbContext.createMarshaller();
   marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);         
   marshaller.marshal(employeeFormat,os);
   outEmpFile(new ByteArrayInputStream(os.toByteArray())); 
  </code></pre>
  
  <p>This method produces the outFile taking the xml as input</p>
  
  <pre><code>public void outEmpFile(ByteArrayInputStream inputStream) throws IOException {
      File template = new File("C/workspace/files/Employee.xslt"); 
      File outFile = new File(C:/workspace/files/Employee.java");
  
      TransformerFactory transformerFactory = TransformerFactory.newInstance();
      Transformer transformer = transformerFactory.newTransformer(new StreamSource(template));             
      transformer.transform(new StreamSource(inputStream),new StreamResult(outFile));
  }
  </code></pre>
  
  <p>I get TransformerException when running the code : </p>
  
  <pre><code> ERROR:  'Premature end of file.'javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: 
  
    com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Premature end of file.
  </code></pre>
  
  <p>Both input xml and xslt produces expected output in online tool - <a href="http://www.utilities-online.info/xsltransformation" rel="nofollow noreferrer">http://www.utilities-online.info/xsltransformation</a>. </p>
  
  <p>This code gives the correct xml file in console.</p>
  
  <pre><code>public void  byteToString(ByteArrayInputStream is) {       
      int size = is.available();
      char[] theChars = new char[size];
      byte[] bytes    = new byte[size];
  
   is.read(bytes, 0, size);
      for (int i = 0; i &lt; size;)
          theChars[i] = (char)(bytes[i++]&amp;0xff);
  
      System.out.println("Xml String :"+ new String(theChars));
    }
  </code></pre>
  
  <p>Any help on the issue please?</p>