if (fileList == null || fileList.length <= 0) { ZipEntry entry = new ZipEntry(rootPath + '/'); entry.setComment(comment); zos.putNextEntry(entry); zos.closeEntry(); is = new BufferedInputStream(new FileInputStream(srcFile)); ZipEntry entry = new ZipEntry(rootPath); entry.setComment(comment); zos.putNextEntry(entry); byte buffer[] = new byte[BUFFER_LEN];
public static void addFolderToZip(ZipOutputStream zos, String path, String comment) throws IOException { while (path.length() != 0 && path.charAt(0) == '/') { path = path.substring(1); } // add folder record if (!StringUtil.endsWithChar(path, '/')) { path += '/'; } ZipEntry zipEntry = new ZipEntry(path); zipEntry.setTime(System.currentTimeMillis()); if (comment != null) { zipEntry.setComment(comment); } zipEntry.setSize(0); zipEntry.setCrc(0); zos.putNextEntry(zipEntry); zos.closeEntry(); }
@Override public void addEntry( String filename, String extension ) throws IOException { // remove folder hierarchy int index = filename.lastIndexOf( Const.FILE_SEPARATOR ); String entryPath; if ( index != -1 ) { entryPath = filename.substring( index + 1 ); } else { entryPath = filename; } // remove ZIP extension index = entryPath.toLowerCase().lastIndexOf( ".zip" ); if ( index != -1 ) { entryPath = entryPath.substring( 0, index ) + entryPath.substring( index + ".zip".length() ); } // add real extension if needed if ( !Utils.isEmpty( extension ) ) { entryPath += "." + extension; } ZipEntry zipentry = new ZipEntry( entryPath ); zipentry.setComment( "Compressed by Kettle" ); ( (ZipOutputStream) delegate ).putNextEntry( zipentry ); } }
/** * Adds byte content into the zip as a file. */ public static void addToZip(ZipOutputStream zos, byte[] content, String path, String comment) throws IOException { while (path.length() != 0 && path.charAt(0) == '/') { path = path.substring(1); } if (StringUtil.endsWithChar(path, '/')) { path = path.substring(0, path.length() - 1); } ZipEntry zipEntry = new ZipEntry(path); zipEntry.setTime(System.currentTimeMillis()); if (comment != null) { zipEntry.setComment(comment); } zos.putNextEntry(zipEntry); InputStream is = new ByteArrayInputStream(content); try { StreamUtil.copy(is, zos); } finally { StreamUtil.close(is); } zos.closeEntry(); }
public static void addFolderToZip(final ZipOutputStream zos, String path, final String comment) throws IOException { while (path.length() != 0 && path.charAt(0) == '/') { path = path.substring(1); } // add folder record if (!StringUtil.endsWithChar(path, '/')) { path += '/'; } ZipEntry zipEntry = new ZipEntry(path); zipEntry.setTime(System.currentTimeMillis()); if (comment != null) { zipEntry.setComment(comment); } zipEntry.setSize(0); zipEntry.setCrc(0); zos.putNextEntry(zipEntry); zos.closeEntry(); }
/** * Adds byte content into the zip as a file. */ public static void addToZip(final ZipOutputStream zos, final byte[] content, String path, final String comment) throws IOException { while (path.length() != 0 && path.charAt(0) == '/') { path = path.substring(1); } if (StringUtil.endsWithChar(path, '/')) { path = path.substring(0, path.length() - 1); } ZipEntry zipEntry = new ZipEntry(path); zipEntry.setTime(System.currentTimeMillis()); if (comment != null) { zipEntry.setComment(comment); } zos.putNextEntry(zipEntry); InputStream is = new ByteArrayInputStream(content); try { StreamUtil.copy(is, zos); } finally { StreamUtil.close(is); } zos.closeEntry(); }
public ZipEntry newZipEntry(ZipEntry ze) { ZipEntry ze2 = new ZipEntry(ze.getName()); ze2.setComment(ze.getComment()); ze2.setTime(ze.getTime()); ze2.setExtra(ze.getExtra()); return ze2; }
zipEntry.setComment(comment);
outEntry.setComment(entry.getComment()); outEntry.setSize(bytes.length);
outEntry.setComment(entry.getComment()); outEntry.setSize(bytes.length);
outEntry.setComment(entry.getComment()); outEntry.setSize(bytes.length);
zipEntry.setComment(comment);
outEntry.setComment(entry.getComment()); outEntry.setSize(bytes.length);
outputEntry.setComment(inputEntry.getComment()); outputEntry.setTime(inputEntry.getTime()); if (compression) {
PKG, "ResourceUtil.SerializeResourceExportInterface.ZipEntryComment.OriginatingFile", filename, Const.NVL( resourceDefinition.getOrigin(), "-" ) ); zipEntry.setComment( comment ); out.putNextEntry( zipEntry );
/** * Copy entry with another name. * * @param original - zipEntry to copy * @param newName - new entry name, optional, if null, ogirinal's entry * @return copy of the original entry, but with the given name */ static ZipEntry copy(ZipEntry original, String newName) { ZipEntry copy = new ZipEntry(newName == null ? original.getName() : newName); if (original.getCrc() != -1) { copy.setCrc(original.getCrc()); } if (original.getMethod() != -1) { copy.setMethod(original.getMethod()); } if (original.getSize() >= 0) { copy.setSize(original.getSize()); } if (original.getExtra() != null) { copy.setExtra(original.getExtra()); } copy.setComment(original.getComment()); copy.setTime(original.getTime()); return copy; }
File entry = new File( buildFilename( false ) ); ZipEntry zipentry = new ZipEntry( entry.getName() ); zipentry.setComment( "Compressed by Kettle" ); data.zip.putNextEntry( zipentry ); outputStream = data.zip;
ZipEntry entry = new ZipEntry(rootPath + '/'); if (!ToolStr.isEmpty(comment)) { entry.setComment(comment); ZipEntry entry = new ZipEntry(rootPath); if (!ToolStr.isEmpty(comment)) { entry.setComment(comment);
private void putMimeTypeAsFirstEntry(String mimeType) throws IOException { ZipEntry mimetypeEntry = new ZipEntry("mimetype"); mimetypeEntry.setComment("mimetype=" + mimeType); mimetypeEntry.setMethod(ZipEntry.STORED); mimetypeEntry.setSize(mimeType.getBytes().length); CRC32 crc32 = new CRC32(); crc32.update(mimeType.getBytes()); mimetypeEntry.setCrc(crc32.getValue()); writeZipEntry(mimetypeEntry, mimeType.getBytes()); }
@Override public void write(final ArchiveIn in) throws IOException { final ZipEntry zi = in.entry(); final ZipEntry zo = new ZipEntry(zi.getName()); zo.setTime(zi.getTime()); zo.setComment(zi.getComment()); zos.putNextEntry(zo); for(int c; (c = in.read(data)) != -1;) zos.write(data, 0, c); zos.closeEntry(); }