Here you can find the source of addPath(JarOutputStream outputStream, Path path, String entryName)
private static void addPath(JarOutputStream outputStream, Path path, String entryName) throws Exception
//package com.java2s; //License from project: Apache License import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; public class Main { private static void addPath(JarOutputStream outputStream, Path path, String entryName) throws Exception { outputStream.putNextEntry(new JarEntry(entryName)); if (!Files.isDirectory(path)) { try (InputStream inputStream = Files.newInputStream(path)) { while (inputStream.available() > 0) { outputStream.write(inputStream.read()); }// w ww . j a v a 2 s . c om } } outputStream.closeEntry(); } }