@Override public void putNextEntry(ZipEntry ze) throws IOException { ze.setTime(dirTime+1999); // roundup super.putNextEntry(ze); } }) {
public static void zip(String parentDir, String[] inputFiles, String outputFile) throws IOException { ZipOutputStream output = null; try { output = new ZipOutputStream(new FileOutputStream(new File(parentDir, outputFile))); for (int i = 0; i < inputFiles.length; i++) { File f = new File(parentDir, inputFiles[i]); FileInputStream input = new FileInputStream(f); output.putNextEntry(new ZipEntry(inputFiles[i])); try { IOUtils.copy(input, output); } finally { input.close(); } } } finally { org.apache.hadoop.io.IOUtils.closeStream(output); } }
if (mode!=-1) dirZipEntry.setUnixMode(mode); dirZipEntry.setTime(f.lastModified()); zip.putNextEntry(dirZipEntry); zip.closeEntry(); } else { if (mode!=-1) fileZipEntry.setUnixMode(mode); fileZipEntry.setTime(f.lastModified()); zip.putNextEntry(fileZipEntry); try (InputStream in = Files.newInputStream(f.toPath())) { int len;
VirtualFile f = dir.child(n); e.setTime(f.lastModified()); zos.putNextEntry(e); try (InputStream in = f.open()) { IOUtils.copy(in, zos);
zOut.putNextEntry(ze);
zOut.putNextEntry(ze);
/** * @param file * @param out * @param basedir * @throws IOException */ private static void compress(Path sourceFilePath, ZipOutputStream out, String basedir) throws IOException { if (Files.isDirectory(sourceFilePath)) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(sourceFilePath);) { for (Path entry : stream) { BasicFileAttributes attrs = Files.readAttributes(entry, BasicFileAttributes.class); String fullName = Constants.BLANK.equals(basedir) ? entry.toFile().getName() : basedir + Constants.SEPARATOR + entry.toFile().getName(); if (attrs.isDirectory()) { ZipEntry zipEntry = new ZipEntry(fullName + Constants.SEPARATOR); out.putNextEntry(zipEntry); compress(entry, out, fullName); } else { compressFile(entry.toFile(), out, fullName); } } } catch (IOException e) { } } else { compressFile(sourceFilePath.toFile(), out, sourceFilePath.toFile().getName()); } }
/** * @param file * @param out * @param basedir * @throws IOException */ private static void compress(Path sourceFilePath, ZipOutputStream out, String basedir) throws IOException { if (Files.isDirectory(sourceFilePath)) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(sourceFilePath);) { for (Path entry : stream) { BasicFileAttributes attrs = Files.readAttributes(entry, BasicFileAttributes.class); String fullName = Constants.BLANK.equals(basedir) ? entry.toFile().getName() : basedir + Constants.SEPARATOR + entry.toFile().getName(); if (attrs.isDirectory()) { ZipEntry zipEntry = new ZipEntry(fullName + Constants.SEPARATOR); out.putNextEntry(zipEntry); compress(entry, out, fullName); } else { compressFile(entry.toFile(), out, fullName); } } } catch (IOException e) { } } else { compressFile(sourceFilePath.toFile(), out, sourceFilePath.toFile().getName()); } }
/** * @param file * @param out * @param basedir * @throws IOException */ private static void compressFile(File file, ZipOutputStream out, String fullName) throws IOException { if (CommonUtils.notEmpty(file)) { ZipEntry entry = new ZipEntry(fullName); entry.setTime(file.lastModified()); out.putNextEntry(entry); try (FileInputStream fis = new FileInputStream(file);) { StreamUtils.copy(fis, out); } } }
/** * @param file * @param out * @param basedir * @throws IOException */ private static void compressFile(File file, ZipOutputStream out, String fullName) throws IOException { if (CommonUtils.notEmpty(file)) { ZipEntry entry = new ZipEntry(fullName); entry.setTime(file.lastModified()); out.putNextEntry(entry); try (FileInputStream fis = new FileInputStream(file);) { StreamUtils.copy(fis, out); } } }
/** * @param p_EntryName * @throws APPErrorException */ private void addZipEntry(String p_EntryName) throws APPErrorException { ZipEntry zipEntry = new ZipEntry(p_EntryName); try { m_ZipOutputStream.putNextEntry(zipEntry); } catch (IOException e) { e.printStackTrace(); } }
@Override public void putNextEntry(ZipEntry ze) throws IOException { ze.setTime(dirTime+1999); // roundup super.putNextEntry(ze); } }) {
private static void writeRecursive(ZipOutputStream zos, BufferedOutputStream bo,String p_FileName,byte[] p_FileData) throws IOException, FileNotFoundException { ZipEntry zipEntry = new ZipEntry(p_FileName); zos.putNextEntry(zipEntry); bo.write(p_FileData); bo.flush(); } /**
private static void writePack(Map<ZipEntry, byte[]> readZipAllEntry, ZipFile file, String path, String channel) throws Exception { ZipOutputStream zot = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(path))); Iterator<ZipEntry> iterator = readZipAllEntry.keySet().iterator(); while (iterator.hasNext()) { ZipEntry entry = iterator.next(); zot.putNextEntry(entry); byte[] data = readZipAllEntry.get(entry); zot.write(data, 0, data.length); // System.out.println(entry); // System.out.println(entry.getSize() + " ," + // entry.getCompressedSize() + "," + data.length); zot.closeEntry(); } zot.putNextEntry(new ZipEntry("META-INF/channel_" + channel)); zot.closeEntry(); zot.close(); }
public static void zip(String parentDir, String[] inputFiles, String outputFile) throws IOException { ZipOutputStream output = null; try { output = new ZipOutputStream(new FileOutputStream(new File(parentDir, outputFile))); for (int i = 0; i < inputFiles.length; i++) { File f = new File(parentDir, inputFiles[i]); FileInputStream input = new FileInputStream(f); output.putNextEntry(new ZipEntry(inputFiles[i])); try { IOUtils.copy(input, output); } finally { input.close(); } } } finally { org.apache.hadoop.io.IOUtils.closeStream(output); } }
public void visit(File f, String relativePath) throws IOException { if(f.isDirectory()) { ZipEntry dirZipEntry = new ZipEntry(relativePath+'/'); // Setting this bit explicitly is needed by some unzipping applications (see HUDSON-3294). dirZipEntry.setExternalAttributes(BITMASK_IS_DIRECTORY); zip.putNextEntry(dirZipEntry); zip.closeEntry(); } else { zip.putNextEntry(new ZipEntry(relativePath)); FileInputStream in = new FileInputStream(f); int len; while((len=in.read(buf))>0) zip.write(buf,0,len); in.close(); zip.closeEntry(); } entriesWritten++; }
public void visit(File f, String relativePath) throws IOException { if(f.isDirectory()) { ZipEntry dirZipEntry = new ZipEntry(relativePath+'/'); // Setting this bit explicitly is needed by some unzipping applications (see HUDSON-3294). dirZipEntry.setExternalAttributes(BITMASK_IS_DIRECTORY); zip.putNextEntry(dirZipEntry); zip.closeEntry(); } else { zip.putNextEntry(new ZipEntry(relativePath)); FileInputStream in = new FileInputStream(f); int len; while((len=in.read(buf))>0) zip.write(buf,0,len); in.close(); zip.closeEntry(); } entriesWritten++; }
private void addFile (org.apache.tools.zip.ZipEntry entry, ZipOutputStream zip_out, InputStream in, long size, byte[] buf) throws IOException { entry.setTime(System.currentTimeMillis()); entry.setSize(size); zip_out.putNextEntry(entry); FileUtil.copyStream(in, zip_out, buf); zip_out.closeEntry(); } }
private void visitDir(FileCopyDetails dirDetails) { try { // Trailing slash in name indicates that entry is a directory ZipEntry archiveEntry = new ZipEntry(dirDetails.getRelativePath().getPathString() + '/'); archiveEntry.setTime(getArchiveTimeFor(dirDetails)); archiveEntry.setUnixMode(UnixStat.DIR_FLAG | dirDetails.getMode()); zipOutStr.putNextEntry(archiveEntry); zipOutStr.closeEntry(); } catch (Exception e) { throw new GradleException(String.format("Could not add %s to ZIP '%s'.", dirDetails, zipFile), e); } } }
private void visitFile(FileCopyDetails fileDetails) { try { ZipEntry archiveEntry = new ZipEntry(fileDetails.getRelativePath().getPathString()); archiveEntry.setTime(getArchiveTimeFor(fileDetails)); archiveEntry.setUnixMode(UnixStat.FILE_FLAG | fileDetails.getMode()); zipOutStr.putNextEntry(archiveEntry); fileDetails.copyTo(zipOutStr); zipOutStr.closeEntry(); } catch (Exception e) { throw new GradleException(String.format("Could not add %s to ZIP '%s'.", fileDetails, zipFile), e); } }