Package java.util.jar

Examples of java.util.jar.JarOutputStream


          // Convert the string to a input stream
          InputStream is = new ByteArrayInputStream(sb.toString().getBytes("UTF-8"));
          Manifest mf = new Manifest(is);

          out = new JarOutputStream(new FileOutputStream(file), mf);
        } else {
          out = new JarOutputStream(new FileOutputStream(file));
        }
      } else if(file.getName().endsWith(".zip")) {
        out = new ZipOutputStream(new FileOutputStream(file));
      }
View Full Code Here


     * @throws IOException
     */
    public Jarer(File jar) throws FileNotFoundException,
                          IOException
    {
        this.jos = new JarOutputStream( new FileOutputStream( jar ) );
    }
View Full Code Here

     */
    public Jarer(File jar,
                 boolean append) throws FileNotFoundException,
                                IOException
    {
        this.jos = new JarOutputStream( new FileOutputStream( jar,
                                                              append ) );
    }
View Full Code Here

     * @throws IOException
     */
    public Jarer(ByteArrayOutputStream outputStream) throws FileNotFoundException,
                                                    IOException
    {
        this.jos = new JarOutputStream( outputStream );
    }
View Full Code Here

   * @return true if successful
   */
  private boolean openOutputStream(File outJar) {
    try {
      OutputStream os = FileUtil.makeOutputStream(buildConfig.getOutputJar());
      zos = new JarOutputStream(os, getWeaver().getManifest(true));
    } catch (IOException ex) {
      IMessage message = new Message("Unable to open outjar " + outJar.getPath() + "(" + ex.getMessage() + ")",
          new SourceLocation(outJar, 0), true);
      handler.handleMessage(message);
      return false;
View Full Code Here

    protected void createJar( File jarFile, Map includes )
        throws IOException
    {
        jarFile.getParentFile().mkdirs();
        FileOutputStream fos = new FileOutputStream( jarFile );
        JarOutputStream jos = null;
        try
        {
            if ( includes.containsKey( MF ) )
            {
                jos = new JarOutputStream( fos );
            }
            else
            {
                jos = new JarOutputStream( fos, createManifest() );
            }
            addEntries( jos, includes );
        }
        finally
        {
View Full Code Here

    }
   
    @Override
    public void create(String repoName, List<String> features, PrintStream console) {
        FileOutputStream fos = null;
        JarOutputStream jos = null;
        try {
            Repository repo = featuresService.getRepository(repoName);
            if (repo == null) {
                throw new RuntimeException("Could not find a repository with name " + repoName);
            }
            String karPath = storage + File.separator + repoName + ".kar";
            File karFile = new File(karPath);
            karFile.getParentFile().mkdirs();
            fos = new FileOutputStream(karFile);
            Manifest manifest = createNonAutoStartManifest(repo.getURI());
            jos = new JarOutputStream(new BufferedOutputStream(fos, 100000), manifest);
           
            Map<URI, Integer> locationMap = new HashMap<URI, Integer>();
            copyResourceToJar(jos, repo.getURI(), locationMap);
       
            Map<String, Feature> featureMap = new HashMap<String, Feature>();
View Full Code Here

        if (!dir.isDirectory()) { // must be a packed (JAR-formatted) plugin
            try {
                File temp = new File(dir.getParentFile(), dir.getName() + ".temp");
                JarFile input = new JarFile(dir);
                Manifest manifest = input.getManifest();
                JarOutputStream out = manifest == null ? new JarOutputStream(
                        new BufferedOutputStream(new FileOutputStream(temp)))
                        : new JarOutputStream(new BufferedOutputStream(new FileOutputStream(temp)), manifest);
                Enumeration en = input.entries();
                byte[] buf = new byte[4096];
                int count;
                while (en.hasMoreElements()) {
                    JarEntry entry = (JarEntry) en.nextElement();
                    if (entry.getName().equals("META-INF/geronimo-plugin.xml")) {
                        entry = new JarEntry(entry.getName());
                        out.putNextEntry(entry);
                        PluginXmlUtil.writePluginMetadata(metadata, out);
                    } else if (entry.getName().equals("META-INF/MANIFEST.MF")) {
                        // do nothing, already passed in a manifest
                    } else {
                        out.putNextEntry(entry);
                        InputStream in = input.getInputStream(entry);
                        while ((count = in.read(buf)) > -1) {
                            out.write(buf, 0, count);
                        }
                        in.close();
                        out.closeEntry();
                    }
                }
                out.flush();
                out.close();
                input.close();
                if (!dir.delete()) {
                    log.error("Unable to delete old plugin at " + dir.getAbsolutePath());
                    throw new IOException("Unable to delete old plugin at " + dir.getAbsolutePath());
                }
View Full Code Here

        resourceAttributes.putValue("drink", "margarita");
        manifest.getEntries().put("resource", resourceAttributes);

        File targetDir = new File(BASEDIR, "target");
        jarFile = new File(targetDir, "resourceFinderTest.jar");
        JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream(jarFile), manifest);
        jarOutputStream.putNextEntry(new ZipEntry("resource"));
        jarOutputStream.write("resource3".getBytes());
        jarOutputStream.putNextEntry(new ZipEntry("jar3"));
        jarOutputStream.write("jar3".getBytes());
        IoUtil.close(jarOutputStream);

        alternateJarFile = new File(targetDir, "alternate.jar");
        log.debug(alternateJarFile.getAbsolutePath());
        jarOutputStream = new JarOutputStream(new FileOutputStream(alternateJarFile), manifest);
        jarOutputStream.putNextEntry(new ZipEntry("resource"));
        jarOutputStream.write("resource4".getBytes());
        jarOutputStream.putNextEntry(new ZipEntry("jar4"));
        jarOutputStream.write("jar4".getBytes());
        IoUtil.close(jarOutputStream);

        testResource = new File(targetDir, "testResource");
        FileOutputStream fileOutputStream = new FileOutputStream(testResource);
        fileOutputStream.write("testResource".getBytes());
View Full Code Here

        generateLocalWSDL(context);
       
      
        File clientJarFile = new File((String)context.get(ToolConstants.CFG_OUTPUTDIR),
                                      (String)context.get(ToolConstants.CFG_CLIENT_JAR));
        JarOutputStream jarout = null;
        try {
            jarout = new JarOutputStream(new FileOutputStream(clientJarFile), new Manifest());
            createClientJar(tmpDir, jarout);
            jarout.close();
        } catch (Exception e) {
            LOG.log(Level.SEVERE, "FAILED_TO_CREAT_CLIENTJAR", e);
            Message msg = new Message("FAILED_TO_CREAT_CLIENTJAR", LOG);
            throw new ToolException(msg, e);
        }   
View Full Code Here

TOP

Related Classes of java.util.jar.JarOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.