本文整理了Java中java.util.zip.ZipEntry.setComment()
方法的一些代码示例,展示了ZipEntry.setComment()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipEntry.setComment()
方法的具体详情如下:
包路径:java.util.zip.ZipEntry
类名称:ZipEntry
方法名:setComment
[英]Sets the comment for this ZipEntry.
[中]设置此ZipEntry的注释。
代码示例来源:origin: Blankj/AndroidUtilCode
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];
代码示例来源:origin: redisson/redisson
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();
}
代码示例来源:origin: pentaho/pentaho-kettle
@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 );
}
}
代码示例来源:origin: redisson/redisson
/**
* 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();
}
代码示例来源:origin: oblac/jodd
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();
}
代码示例来源:origin: oblac/jodd
/**
* 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();
}
代码示例来源:origin: spotbugs/spotbugs
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;
}
代码示例来源:origin: redisson/redisson
zipEntry.setComment(comment);
代码示例来源:origin: google/j2objc
outEntry.setComment(entry.getComment());
outEntry.setSize(bytes.length);
代码示例来源:origin: org.easymock/easymock
outEntry.setComment(entry.getComment());
outEntry.setSize(bytes.length);
代码示例来源:origin: cglib/cglib
outEntry.setComment(entry.getComment());
outEntry.setSize(bytes.length);
代码示例来源:origin: oblac/jodd
zipEntry.setComment(comment);
代码示例来源:origin: cglib/cglib
outEntry.setComment(entry.getComment());
outEntry.setSize(bytes.length);
代码示例来源:origin: org.apache.ant/ant
outputEntry.setComment(inputEntry.getComment());
outputEntry.setTime(inputEntry.getTime());
if (compression) {
代码示例来源:origin: pentaho/pentaho-kettle
PKG, "ResourceUtil.SerializeResourceExportInterface.ZipEntryComment.OriginatingFile", filename,
Const.NVL( resourceDefinition.getOrigin(), "-" ) );
zipEntry.setComment( comment );
out.putNextEntry( zipEntry );
代码示例来源:origin: zeroturnaround/zt-zip
/**
* 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;
}
代码示例来源:origin: pentaho/pentaho-kettle
File entry = new File( buildFilename( false ) );
ZipEntry zipentry = new ZipEntry( entry.getName() );
zipentry.setComment( "Compressed by Kettle" );
data.zip.putNextEntry( zipentry );
outputStream = data.zip;
代码示例来源:origin: SeanDragon/protools
ZipEntry entry = new ZipEntry(rootPath + '/');
if (!ToolStr.isEmpty(comment)) {
entry.setComment(comment);
ZipEntry entry = new ZipEntry(rootPath);
if (!ToolStr.isEmpty(comment)) {
entry.setComment(comment);
代码示例来源:origin: no.difi.commons/commons-asic
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());
}
代码示例来源:origin: BaseXdb/basex
@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();
}
内容来源于网络,如有侵权,请联系作者删除!