title: Java Applet slow when using ByteArrayStream
body: <p>I am transforming xml in an object of an own class called "V6BasicCar", the problem that I'm having is that if I enable the Java cache (in Java control panel):</p>
  
  <p><img src="https://i.stack.imgur.com/P532Z.gif" alt="enter image description here"></p>
  
  <p>each transformation takes about 3-4 seconds, but if I disable caching, it takes just miliseconds. I don't know why this happens, my only guess is that Java is caching the ByteArrayStream  per transformation and that makes it slower, but I haven't figured out how to deal with this problem. Is there any alternative to ByteArray Stream that would be faster?</p>
  
  <p>Thanks.</p>
  
  <p>The code:</p>
  
  <pre><code>{
  ..
  
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  
  //1. transform xml    
  transform(getSourceXml(_intype), out);
  
  //2. convert to bean
  XsdConverter&lt;V6BasicCar&gt; v6BasicCarXsdConverter = new XsdConverter&lt;V6BasicCar&gt;(V6BasicCar.class);     
      /* 
      "getObject()" takes about 2 secs 
      */
  V6BasicCar newV6BasicCar = v6BasicCarXsdConverter.getObject(convert(out));
  
  ..
  }
  
  
   protected InputStream getSourceXml(final CsvWrapperMiddle _csvV6Car) throws IOException, JAXBException
  {
      ByteArrayOutputStream out = new ByteArrayOutputStream();   
  
          /* 
          "getXml" takes about 2 secs 
          */
      xsdConverter.getXml(_csvV6Car.getExternalBean(), out); 
      InputStream output = convert(out);   
      return output;
  }
  
  protected InputStream convert(ByteArrayOutputStream out)
  {
      return new ByteArrayInputStream(out.toByteArray());
  }
  </code></pre>