Java Path File Name nio addPath(JarOutputStream outputStream, Path path, String entryName)

Here you can find the source of addPath(JarOutputStream outputStream, Path path, String entryName)

Description

add Path

License

Apache License

Declaration

private static void addPath(JarOutputStream outputStream, Path path, String entryName) throws Exception 

Method Source Code


//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();
    }
}

Related

  1. addRestorePermissions(String username, Path file)
  2. appendTargetToBuildFile(String targetName, Path dir)
  3. checkFile(final String friendlyname, final Path file, final boolean isdirectory, final boolean canwrite)
  4. compileAndLoad(Path basePath, String className)