Esempio n. 1
0
  protected void addFileToJar(String className, String classFile, JarOutputStream jar)
      throws IOException {
    className = className.replace('\\', '/');
    FileInputStream fio = new FileInputStream(classFile);
    jar.putNextEntry(new JarEntry(className));

    int cb;
    byte[] buffer = new byte[8192];
    while ((cb = fio.read(buffer)) != -1) {
      jar.write(buffer, 0, cb);
    }

    jar.closeEntry();
    fio.close();
  }
Esempio n. 2
0
 protected void addRuntimeClasses(JarOutputStream jar) throws IOException {
   ClassLoader cl = Thread.currentThread().getContextClassLoader();
   if (cl == null) {
     cl = getClass().getClassLoader();
   }
   ArrayList<String> runtimeClasses = getRuntimeClasses(cl);
   for (String c : runtimeClasses) {
     jar.putNextEntry(new JarEntry(c));
     InputStream in = cl.getResourceAsStream(c);
     int ch;
     while ((ch = in.read()) != -1) {
       jar.write((char) ch);
     }
     jar.closeEntry();
     in.close();
   }
 }