[jboss-dev-forums] [Design of POJO Server] - Re: VirtualFile.toURL() returning vfsfile:

bill.burke@jboss.com do-not-reply at jboss.com
Wed Oct 25 15:54:02 EDT 2006


Found out more things:

* If I read the JarEntries stream into a ByteArrayInputStream, then everything is cool

to be able to read into a BAIS, for some reason, I have to loop on the read or it doesn't work:

  |          ByteArrayOutputStream baos = new ByteArrayOutputStream((int)size);
  |          int wasRead = 0;
  |          byte[] tmp = new byte[1024];
  |          while( is.available() > 0 )
  |          {
  |             int length = is.read(tmp);
  |             if( length > 0 )
  |                baos.write(tmp, 0, length);
  |             wasRead += length;
  |          }
  |          is.close();
  |          byte[] bytes = baos.toByteArray();
  | 

* A better way to get a unique/copy of the InputStream for the JarEntry.  I used URL's for this:


  | URLConnection con = jarEntryUrl.openConnection();
  | con.setUseCaches(false);
  | return con.getInputStream();
  | 

This works beautifully.  Now the question is, how slow is this MOFO?


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3980823#3980823

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3980823



More information about the jboss-dev-forums mailing list