本文整理匯總了Java中org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.setComment方法的典型用法代碼示例。如果您正苦於以下問題:Java ZipArchiveOutputStream.setComment方法的具體用法?Java ZipArchiveOutputStream.setComment怎麽用?Java ZipArchiveOutputStream.setComment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream
的用法示例。
在下文中一共展示了ZipArchiveOutputStream.setComment方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createContainer
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; //導入方法依賴的package包/類
@Override
protected ZipArchiveOutputStream createContainer(ServletOutputStream sout, String comment) {
ZipArchiveOutputStream zout = new ZipArchiveOutputStream(new BufferedOutputStream(sout));
zout.setComment(comment);
zout.setLevel(Deflater.BEST_COMPRESSION);
return zout;
}
示例2: createZip
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; //導入方法依賴的package包/類
/**
* Create ZIP archive from file
*/
public static void createZip(File path, OutputStream os) throws IOException {
log.debug("createZip({}, {})", new Object[]{path, os});
if (path.exists() && path.canRead()) {
ZipArchiveOutputStream zaos = new ZipArchiveOutputStream(os);
zaos.setComment("Generated by OpenKM");
zaos.setCreateUnicodeExtraFields(UnicodeExtraFieldPolicy.ALWAYS);
zaos.setUseLanguageEncodingFlag(true);
zaos.setFallbackToUTF8(true);
zaos.setEncoding("UTF-8");
log.debug("FILE {}", path);
ZipArchiveEntry zae = new ZipArchiveEntry(path.getName());
zaos.putArchiveEntry(zae);
FileInputStream fis = new FileInputStream(path);
IOUtils.copy(fis, zaos);
fis.close();
zaos.closeArchiveEntry();
zaos.flush();
zaos.finish();
zaos.close();
} else {
throw new IOException("Can't access " + path);
}
log.debug("createZip: void");
}
示例3: zip
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; //導入方法依賴的package包/類
/**
* Zips the contents of the tree at the (optionally) specified revision and the (optionally) specified basepath to the supplied outputstream.
*
* @param repository
* @param basePath
* if unspecified, entire repository is assumed.
* @param objectId
* if unspecified, HEAD is assumed.
* @param os
* @return true if repository was successfully zipped to supplied output stream
*/
public static boolean zip(Repository repository, String basePath, String objectId, OutputStream os) {
RevCommit commit = JGitUtils.getCommit(repository, objectId);
if (commit == null) {
return false;
}
boolean success = false;
RevWalk rw = new RevWalk(repository);
TreeWalk tw = new TreeWalk(repository);
try {
tw.reset();
tw.addTree(commit.getTree());
ZipArchiveOutputStream zos = new ZipArchiveOutputStream(os);
zos.setComment("Generated by Gitblit");
if (!StringUtils.isEmpty(basePath)) {
PathFilter f = PathFilter.create(basePath);
tw.setFilter(f);
}
tw.setRecursive(true);
MutableObjectId id = new MutableObjectId();
ObjectReader reader = tw.getObjectReader();
long modified = commit.getAuthorIdent().getWhen().getTime();
while (tw.next()) {
FileMode mode = tw.getFileMode(0);
if (mode == FileMode.GITLINK || mode == FileMode.TREE) {
continue;
}
tw.getObjectId(id, 0);
ZipArchiveEntry entry = new ZipArchiveEntry(tw.getPathString());
entry.setSize(reader.getObjectSize(id, Constants.OBJ_BLOB));
entry.setComment(commit.getName());
entry.setUnixMode(mode.getBits());
entry.setTime(modified);
zos.putArchiveEntry(entry);
ObjectLoader ldr = repository.open(id);
ldr.copyTo(zos);
zos.closeArchiveEntry();
}
zos.finish();
success = true;
} catch (IOException e) {
error(e, repository, "{0} failed to zip files from commit {1}", commit.getName());
} finally {
tw.close();
rw.close();
rw.dispose();
}
return success;
}
示例4: zip
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; //導入方法依賴的package包/類
/**
* Zips the contents of the tree at the (optionally) specified revision and
* the (optionally) specified basepath to the supplied outputstream.
*
* @param repository
* @param basePath
* if unspecified, entire repository is assumed.
* @param objectId
* if unspecified, HEAD is assumed.
* @param os
* @return true if repository was successfully zipped to supplied output
* stream
*/
public static boolean zip(Repository repository, String basePath, String objectId,
OutputStream os) {
RevCommit commit = JGitUtils.getCommit(repository, objectId);
if (commit == null) {
return false;
}
boolean success = false;
RevWalk rw = new RevWalk(repository);
TreeWalk tw = new TreeWalk(repository);
try {
tw.reset();
tw.addTree(commit.getTree());
ZipArchiveOutputStream zos = new ZipArchiveOutputStream(os);
zos.setComment("Generated by Gitblit");
if (!StringUtils.isEmpty(basePath)) {
PathFilter f = PathFilter.create(basePath);
tw.setFilter(f);
}
tw.setRecursive(true);
MutableObjectId id = new MutableObjectId();
ObjectReader reader = tw.getObjectReader();
long modified = commit.getAuthorIdent().getWhen().getTime();
while (tw.next()) {
FileMode mode = tw.getFileMode(0);
if (mode == FileMode.GITLINK || mode == FileMode.TREE) {
continue;
}
tw.getObjectId(id, 0);
ZipArchiveEntry entry = new ZipArchiveEntry(tw.getPathString());
entry.setSize(reader.getObjectSize(id, Constants.OBJ_BLOB));
entry.setComment(commit.getName());
entry.setUnixMode(mode.getBits());
entry.setTime(modified);
zos.putArchiveEntry(entry);
ObjectLoader ldr = repository.open(id);
ldr.copyTo(zos);
zos.closeArchiveEntry();
}
zos.finish();
success = true;
} catch (IOException e) {
error(e, repository, "{0} failed to zip files from commit {1}", commit.getName());
} finally {
tw.release();
rw.dispose();
}
return success;
}