2 Replies Latest reply: Jun 25, 2010 6:14 PM by Andrew Rubinger RSS

    JavaArchive to VirtualFile

    Thomas Diesler Master

      Is there a way to transform a JavaArchive to a VirtualFile in-memory (i.e. without going to /tmp)

       

      Currently I do this

       

         private void validateBundleArchive(Archive<?> archive) throws Exception
         {
            String archiveName = archive.getName();
            int dotIndex = archiveName.lastIndexOf(".");
            if (dotIndex > 0)
               archiveName = archiveName.substring(0, dotIndex);
            
            // [TODO] Can this be done in memory?
            File target = File.createTempFile(archiveName + "-", ".jar");
            try
            {
               ZipExporter exporter = archive.as(ZipExporter.class);
               exporter.exportZip(target, true);
               VirtualFile virtualFile = AbstractVFS.getRoot(target.toURI().toURL());
               BundleInfo.createBundleInfo(virtualFile);
            }
            finally
            {
               target.delete();
            }