jodd-core/src/main/java/jodd/io/ZipUtil.java
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 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 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 ( ) ; }
Adds byte content into the zip as a file.
Adds byte content into the zip as a file .