- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中java.util.zip.ZipEntry.setMethod()
方法的一些代码示例,展示了ZipEntry.setMethod()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipEntry.setMethod()
方法的具体详情如下:
包路径:java.util.zip.ZipEntry
类名称:ZipEntry
方法名:setMethod
[英]Sets the compression method for this entry to either DEFLATED or STORED. The default is DEFLATED, which will cause the size, compressed size, and CRC to be set automatically, and the entry's data to be compressed. If you switch to STOREDnote that you'll have to set the size (or compressed size; they must be the same, but it's okay to only set one) and CRC yourself because they must appear before the user data in the resulting zip file. See #setSize and #setCrc.
[中]将此条目的压缩方法设置为“已放气”或“已存储”。默认值为DEFLATED,这将导致自动设置大小、压缩大小和CRC,并压缩条目的数据。如果切换到STOREDnote,则必须自行设置大小(或压缩大小;它们必须相同,但可以只设置一个)和CRC,因为它们必须出现在生成的zip文件中的用户数据之前。请参阅#设置大小和#设置CRC。
代码示例来源:origin: Tencent/tinker
private static void zipFile(File resFile, ZipOutputStream zipout, String rootpath) throws IOException {
rootpath = rootpath + (rootpath.trim().length() == 0 ? "" : File.separator) + resFile.getName();
if (resFile.isDirectory()) {
File[] fileList = resFile.listFiles();
for (File file : fileList) {
zipFile(file, zipout, rootpath);
}
} else {
final byte[] fileContents = readContents(resFile);
//linux format!!
if (rootpath.contains("\\")) {
rootpath = rootpath.replace("\\", "/");
}
ZipEntry entry = new ZipEntry(rootpath);
// if (compressMethod == ZipEntry.DEFLATED) {
entry.setMethod(ZipEntry.DEFLATED);
// } else {
// entry.setMethod(ZipEntry.STORED);
// entry.setSize(fileContents.length);
// final CRC32 checksumCalculator = new CRC32();
// checksumCalculator.update(fileContents);
// entry.setCrc(checksumCalculator.getValue());
// }
zipout.putNextEntry(entry);
zipout.write(fileContents);
zipout.flush();
zipout.closeEntry();
}
}
代码示例来源:origin: scouter-project/scouter
static public void sendZipFile(ZipOutputStream zos, File file) throws Exception {
String zipFilename = file.getAbsolutePath();
int index = zipFilename.lastIndexOf(File.separator);
if(index >= 0){
zipFilename = zipFilename.substring(index+1);
}
ZipEntry zipEntry = new ZipEntry(zipFilename);
zipEntry.setMethod(ZipEntry.DEFLATED);
zipEntry.setSize(file.length());
zos.putNextEntry(zipEntry);
int readSize = 0;
byte[] buffer = new byte[FILE_BUFFER_SIZE];
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
while (0 != (readSize = bis.read(buffer))) {
if(-1 == readSize) break;
zos.write(buffer, 0, readSize);
}
bis.close();
}
代码示例来源:origin: scouter-project/scouter
static public void sendZipFile(ZipOutputStream zos, File file) throws Exception {
String zipFilename = file.getAbsolutePath();
int index = zipFilename.lastIndexOf(File.separator);
if(index >= 0){
zipFilename = zipFilename.substring(index+1);
}
ZipEntry zipEntry = new ZipEntry(zipFilename);
zipEntry.setMethod(ZipEntry.DEFLATED);
zipEntry.setSize(file.length());
zos.putNextEntry(zipEntry);
int readSize = 0;
byte[] buffer = new byte[FILE_BUFFER_SIZE];
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
while (0 != (readSize = bis.read(buffer))) {
if(-1 == readSize) break;
zos.write(buffer, 0, readSize);
}
bis.close();
}
代码示例来源:origin: iBotPeaches/Apktool
private void copyUnknownFiles(File appDir, ZipOutputStream outputFile, Map<String, String> files)
throws BrutException, IOException {
File unknownFileDir = new File(appDir, UNK_DIRNAME);
// loop through unknown files
for (Map.Entry<String,String> unknownFileInfo : files.entrySet()) {
File inputFile = new File(unknownFileDir, BrutIO.sanitizeUnknownFile(unknownFileDir, unknownFileInfo.getKey()));
if (inputFile.isDirectory()) {
continue;
}
ZipEntry newEntry = new ZipEntry(unknownFileInfo.getKey());
int method = Integer.parseInt(unknownFileInfo.getValue());
LOGGER.fine(String.format("Copying unknown file %s with method %d", unknownFileInfo.getKey(), method));
if (method == ZipEntry.STORED) {
newEntry.setMethod(ZipEntry.STORED);
newEntry.setSize(inputFile.length());
newEntry.setCompressedSize(-1);
BufferedInputStream unknownFile = new BufferedInputStream(new FileInputStream(inputFile));
CRC32 crc = BrutIO.calculateCrc(unknownFile);
newEntry.setCrc(crc.getValue());
} else {
newEntry.setMethod(ZipEntry.DEFLATED);
}
outputFile.putNextEntry(newEntry);
BrutIO.copy(inputFile, outputFile);
outputFile.closeEntry();
}
}
代码示例来源:origin: scouter-project/scouter
static public void sendZipFile(ZipOutputStream zos, File file) throws Exception {
String zipFilename = file.getAbsolutePath();
int index = zipFilename.lastIndexOf(File.separator);
if(index >= 0){
zipFilename = zipFilename.substring(index+1);
}
ZipEntry zipEntry = new ZipEntry(zipFilename);
zipEntry.setMethod(ZipEntry.DEFLATED);
zipEntry.setSize(file.length());
zos.putNextEntry(zipEntry);
int readSize = 0;
byte[] buffer = new byte[FILE_BUFFER_SIZE];
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
while (0 != (readSize = bis.read(buffer))) {
if(-1 == readSize) break;
zos.write(buffer, 0, readSize);
}
bis.close();
}
代码示例来源:origin: scouter-project/scouter
static public void sendZipFile(ZipOutputStream zos, File file) throws Exception {
String zipFilename = file.getAbsolutePath();
int index = zipFilename.lastIndexOf(File.separator);
if(index >= 0){
zipFilename = zipFilename.substring(index+1);
}
ZipEntry zipEntry = new ZipEntry(zipFilename);
zipEntry.setMethod(ZipEntry.DEFLATED);
zipEntry.setSize(file.length());
zos.putNextEntry(zipEntry);
int readSize = 0;
byte[] buffer = new byte[FILE_BUFFER_SIZE];
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
while (0 != (readSize = bis.read(buffer))) {
if(-1 == readSize) break;
zos.write(buffer, 0, readSize);
}
bis.close();
}
代码示例来源:origin: iBotPeaches/Apktool
zipEntry.setMethod(ZipEntry.STORED);
zipEntry.setSize(file.length());
BufferedInputStream unknownFile = new BufferedInputStream(new FileInputStream(file));
unknownFile.close();
} else {
zipEntry.setMethod(ZipEntry.DEFLATED);
代码示例来源:origin: scouter-project/scouter
static public void sendZipFile(ZipOutputStream zos, File file) throws Exception {
String zipFilename = file.getAbsolutePath();
int index = zipFilename.lastIndexOf(File.separator);
if(index >= 0){
zipFilename = zipFilename.substring(index+1);
}
ZipEntry zipEntry = new ZipEntry(zipFilename);
zipEntry.setMethod(ZipEntry.DEFLATED);
zipEntry.setSize(file.length());
zos.putNextEntry(zipEntry);
int readSize = 0;
byte[] buffer = new byte[FILE_BUFFER_SIZE];
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
while (0 != (readSize = bis.read(buffer))) {
if(-1 == readSize) break;
zos.write(buffer, 0, readSize);
}
bis.close();
}
代码示例来源:origin: guoguibing/librec
entry.setMethod(ZipEntry.STORED);
entry.setCompressedSize(file.length());
entry.setSize(file.length());
代码示例来源:origin: pxb1988/dex2jar
ZipEntry nEntry = new ZipEntry(e.getName());
nEntry.setMethod(e.getMethod() == com.googlecode.d2j.util.zip.ZipEntry.STORED ? ZipEntry.STORED
: ZipEntry.DEFLATED);
zos.putNextEntry(nEntry);
代码示例来源:origin: Sable/soot
private void copyAllButClassesDexAndSigFiles(ZipFile source, ZipOutputStream destination) throws IOException {
Enumeration<? extends ZipEntry> sourceEntries = source.entries();
while (sourceEntries.hasMoreElements()) {
ZipEntry sourceEntry = sourceEntries.nextElement();
String sourceEntryName = sourceEntry.getName();
if (sourceEntryName.endsWith(".dex") || isSignatureFile(sourceEntryName)) {
continue;
}
// separate ZipEntry avoids compression problems due to encodings
ZipEntry destinationEntry = new ZipEntry(sourceEntryName);
// use the same compression method as the original (certain files
// are stored, not compressed)
destinationEntry.setMethod(sourceEntry.getMethod());
// copy other necessary fields for STORE method
destinationEntry.setSize(sourceEntry.getSize());
destinationEntry.setCrc(sourceEntry.getCrc());
// finally craft new entry
destination.putNextEntry(destinationEntry);
InputStream zipEntryInput = source.getInputStream(sourceEntry);
byte[] buffer = new byte[2048];
int bytesRead = zipEntryInput.read(buffer);
while (bytesRead > 0) {
destination.write(buffer, 0, bytesRead);
bytesRead = zipEntryInput.read(buffer);
}
zipEntryInput.close();
}
}
代码示例来源:origin: google/j2objc
outEntry.setMethod(entry.getMethod());
outEntry.setComment(entry.getComment());
outEntry.setSize(bytes.length);
代码示例来源:origin: zeroturnaround/zt-zip
public ZipEntry getEntry() {
ZipEntry entry = new ZipEntry(path);
if (bytes != null) {
entry.setSize(bytes.length);
}
if(compressionMethod != -1) {
entry.setMethod(compressionMethod);
}
if(crc != -1L) {
entry.setCrc(crc);
}
entry.setTime(time);
return entry;
}
代码示例来源:origin: org.easymock/easymock
outEntry.setMethod(entry.getMethod());
outEntry.setComment(entry.getComment());
outEntry.setSize(bytes.length);
代码示例来源:origin: cglib/cglib
outEntry.setMethod(entry.getMethod());
outEntry.setComment(entry.getComment());
outEntry.setSize(bytes.length);
代码示例来源:origin: cglib/cglib
outEntry.setMethod(entry.getMethod());
outEntry.setComment(entry.getComment());
outEntry.setSize(bytes.length);
代码示例来源:origin: org.apache.ant/ant
outputEntry.setTime(inputEntry.getTime());
if (compression) {
outputEntry.setMethod(ZipEntry.DEFLATED);
outputEntry.setMethod(ZipEntry.STORED);
outputEntry.setCrc(inputEntry.getCrc());
outputEntry.setSize(inputEntry.getSize());
代码示例来源: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: robovm/robovm
ze.setMethod(method);
代码示例来源:origin: robovm/robovm
currentEntry.time = ceLastModifiedTime;
currentEntry.modDate = ceLastModifiedDate;
currentEntry.setMethod(ceCompressionMethod);
if (ceSize != -1) {
currentEntry.setCrc(ceCrc);
最近几天我一直在努力学习类和对象,我意识到在构造函数中使用“this.set”和“set”并没有明显的区别。澄清 public Movie(String title,String director,
本文整理了Java中ij.plugin.ZProjector.setMethod()方法的一些代码示例,展示了ZProjector.setMethod()的具体用法。这些代码示例主要来源于Github
我有兴趣为泛型函数设置新方法。例如,假设我有一个新类(class)(例如 coolClass)。我可以编写一个包装器来计算该类的 log10 并使用以下代码轻松设置该方法: setMethod("Ma
本文整理了Java中java.util.zip.ZipOutputStream.setMethod()方法的一些代码示例,展示了ZipOutputStream.setMethod()的具体用法。这些代
本文整理了Java中java.util.zip.ZipEntry.setMethod()方法的一些代码示例,展示了ZipEntry.setMethod()的具体用法。这些代码示例主要来源于Github
为标题道歉,不知道如何表达这个问题。 如果我想创建 setMethod在一个类(class)上如何区分mat[i,]的类似情况和 mat[i] ? 我知道我可以使用的前者: setMethod("["
题 在 r 中编程时与 s4 OOP系统,何时必须使用 setReplaceMethod ? 我看不出和 setMethod 有什么区别添加时 setReplaceMethod function (
我尝试使用传入的参数创建一个新对象,然后使用该新对象放置在下面列出的 setCarColor 方法中。但是我的构造函数中的 setCarColor 为我的 clv 变量提供了错误。它说“找不到符号”。
我正在尝试创建一个类Tax,它使用扫描仪变量从用户获取工资和税率,并使用用户的输入给出税后工资。 我收到的错误是 set-method 不能用于使用扫描仪变量。请提出解决方案。 代码如下:- pack
浏览 System.Linq.Expressions 的 .NET 核心源代码,我发现以下代码位于 here : MethodInfo mi = property.GetGetMethod(true)
本文整理了Java中org.apache.tools.zip.ZipOutputStream.setMethod()方法的一些代码示例,展示了ZipOutputStream.setMethod()的具
本文整理了Java中de.schlichtherle.truezip.zip.ZipEntry.setMethod()方法的一些代码示例,展示了ZipEntry.setMethod()的具体用法。这些
基本上,当 setMethod 或 (setGeneric) 中有很多参数时,它的运行速度会非常慢。 这是一个基本示例: setClassUnion(name = "mNumeric", member
所以,PropertyInfo 有一个 GetSetMethod 方法,它返回这个属性的 setter 方法。它还有一个 SetMethod 属性(据我所知)。 我问这个是因为如果属性不是公共(pub
经过几个小时的教程和谷歌搜索,我知道当我们在头文件中定义一个属性时,编译器会自动生成 setter 和 getter,这里是一个例子: “example.h” @property(strong,non
本文整理了Java中org.mozilla.zest.core.v1.ZestRequest.setMethod()方法的一些代码示例,展示了ZestRequest.setMethod()的具体用法。
我正在使用 setMethod 来覆盖不同类的对象的“摘要”函数。 最初,我使用了这种方法: setMethod('summary', "class_1", function(o
本文整理了Java中org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.setMethod()方法的一些代码示例,展示了Z
本文整理了Java中org.apache.commons.compress.archivers.zip.ZipArchiveEntry.setMethod()方法的一些代码示例,展示了ZipArchi
我有一些现有代码可以创建 Epub 2 格式的 zip 文件,它可以正常工作。 在尝试更新我的代码以支持 Epub 3 格式时,我想我会尝试使用 Java NIO Zip 文件系统而不是 java.u
我是一名优秀的程序员,十分优秀!