本文整理了Java中org.apache.tools.zip.ZipEntry.setTime()
方法的一些代码示例,展示了ZipEntry.setTime()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipEntry.setTime()
方法的具体详情如下:
包路径:org.apache.tools.zip.ZipEntry
类名称:ZipEntry
方法名:setTime
暂无
代码示例来源:origin: jenkinsci/jenkins
@Override
public void putNextEntry(ZipEntry ze) throws IOException {
ze.setTime(dirTime+1999); // roundup
super.putNextEntry(ze);
}
}) {
代码示例来源:origin: org.apache.ant/ant
/**
* Creates a new zip entry taking some information from the given
* file and using the provided name.
*
* <p>The name will be adjusted to end with a forward slash "/" if
* the file is a directory. If the file is not a directory a
* potential trailing forward slash will be stripped from the
* entry name.</p>
*
* @param inputFile File
* @param entryName String
*/
public ZipEntry(final File inputFile, final String entryName) {
this(inputFile.isDirectory() && !entryName.endsWith("/") ? entryName + "/" : entryName);
if (inputFile.isFile()) {
setSize(inputFile.length());
}
setTime(inputFile.lastModified());
// TODO are there any other fields we can set here?
}
代码示例来源:origin: jenkinsci/jenkins
dirZipEntry.setTime(f.lastModified());
zip.putNextEntry(dirZipEntry);
zip.closeEntry();
ZipEntry fileZipEntry = new ZipEntry(relativePath);
if (mode!=-1) fileZipEntry.setUnixMode(mode);
fileZipEntry.setTime(f.lastModified());
zip.putNextEntry(fileZipEntry);
try (InputStream in = Files.newInputStream(f.toPath())) {
代码示例来源:origin: org.apache.ant/ant
/**
* Provides default values for compression method and last
* modification time.
*
* @param entry ZipEntry
*/
private void setDefaults(ZipEntry entry) {
if (entry.getMethod() == -1) { // not specified
entry.setMethod(method);
}
if (entry.getTime() == -1) { // not specified
entry.setTime(System.currentTimeMillis());
}
}
代码示例来源:origin: jenkinsci/jenkins
e.setTime(f.lastModified());
zos.putNextEntry(e);
try (InputStream in = f.open()) {
代码示例来源:origin: org.apache.ant/ant
ze.setTime(modTimeMillis);
} else if (dir != null && dir.isExists()) {
ze.setTime(dir.getLastModified() + millisToAdd);
} else {
ze.setTime(System.currentTimeMillis() + millisToAdd);
代码示例来源:origin: org.apache.ant/ant
ze.setTime(fixedModTime != null ? modTimeMillis : lastModified);
ze.setMethod(doCompress ? ZipEntry.DEFLATED : ZipEntry.STORED);
代码示例来源:origin: sanluan/PublicCMS
/**
* @param file
* @param out
* @param basedir
* @throws IOException
*/
private static void compressFile(File file, ZipOutputStream out, String fullName) throws IOException {
if (CommonUtils.notEmpty(file)) {
ZipEntry entry = new ZipEntry(fullName);
entry.setTime(file.lastModified());
out.putNextEntry(entry);
try (FileInputStream fis = new FileInputStream(file);) {
StreamUtils.copy(fis, out);
}
}
}
代码示例来源:origin: sanluan/PublicCMS
/**
* @param file
* @param out
* @param basedir
* @throws IOException
*/
private static void compressFile(File file, ZipOutputStream out, String fullName) throws IOException {
if (CommonUtils.notEmpty(file)) {
ZipEntry entry = new ZipEntry(fullName);
entry.setTime(file.lastModified());
out.putNextEntry(entry);
try (FileInputStream fis = new FileInputStream(file);) {
StreamUtils.copy(fis, out);
}
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
@Override
public void putNextEntry(ZipEntry ze) throws IOException {
ze.setTime(dirTime+1999); // roundup
super.putNextEntry(ze);
}
}) {
代码示例来源:origin: hyperic/hq
private void addFile (org.apache.tools.zip.ZipEntry entry,
ZipOutputStream zip_out,
InputStream in,
long size,
byte[] buf) throws IOException {
entry.setTime(System.currentTimeMillis());
entry.setSize(size);
zip_out.putNextEntry(entry);
FileUtil.copyStream(in, zip_out, buf);
zip_out.closeEntry();
}
}
代码示例来源:origin: com.github.javahaohao/utils
fileName = fileName + "/";
ZipEntry entry = new ZipEntry(fileName);
entry.setTime(file.lastModified());
zipOutput.putNextEntry(entry);
String fileNames[] = file.list();
代码示例来源:origin: com.github.javahaohao/utils
ze.setTime(file.lastModified());
ze.setTime(f.lastModified());
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
dirZipEntry.setTime(f.lastModified());
zip.putNextEntry(dirZipEntry);
zip.closeEntry();
ZipEntry fileZipEntry = new ZipEntry(relativePath);
if (mode!=-1) fileZipEntry.setUnixMode(mode);
fileZipEntry.setTime(f.lastModified());
zip.putNextEntry(fileZipEntry);
try (InputStream in = Files.newInputStream(f.toPath())) {
代码示例来源:origin: org.gradle/gradle-core
private void visitDir(FileCopyDetails dirDetails) {
try {
// Trailing slash in name indicates that entry is a directory
ZipEntry archiveEntry = new ZipEntry(dirDetails.getRelativePath().getPathString() + '/');
archiveEntry.setTime(getArchiveTimeFor(dirDetails));
archiveEntry.setUnixMode(UnixStat.DIR_FLAG | dirDetails.getMode());
zipOutStr.putNextEntry(archiveEntry);
zipOutStr.closeEntry();
} catch (Exception e) {
throw new GradleException(String.format("Could not add %s to ZIP '%s'.", dirDetails, zipFile), e);
}
}
}
代码示例来源:origin: org.gradle/gradle-core
private void visitFile(FileCopyDetails fileDetails) {
try {
ZipEntry archiveEntry = new ZipEntry(fileDetails.getRelativePath().getPathString());
archiveEntry.setTime(getArchiveTimeFor(fileDetails));
archiveEntry.setUnixMode(UnixStat.FILE_FLAG | fileDetails.getMode());
zipOutStr.putNextEntry(archiveEntry);
fileDetails.copyTo(zipOutStr);
zipOutStr.closeEntry();
} catch (Exception e) {
throw new GradleException(String.format("Could not add %s to ZIP '%s'.", fileDetails, zipFile), e);
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
private static void zip(OutputStream outputStream, VirtualFile dir, String glob) throws IOException {
try (ZipOutputStream zos = new ZipOutputStream(outputStream)) {
zos.setEncoding(System.getProperty("file.encoding")); // TODO JENKINS-20663 make this overridable via query parameter
for (String n : dir.list(glob.length() == 0 ? "**" : glob)) {
String relativePath;
if (glob.length() == 0) {
// JENKINS-19947: traditional behavior is to prepend the directory name
relativePath = dir.getName() + '/' + n;
} else {
relativePath = n;
}
// In ZIP archives "All slashes MUST be forward slashes" (http://pkware.com/documents/casestudies/APPNOTE.TXT)
// TODO On Linux file names can contain backslashes which should not treated as file separators.
// Unfortunately, only the file separator char of the master is known (File.separatorChar)
// but not the file separator char of the (maybe remote) "dir".
ZipEntry e = new ZipEntry(relativePath.replace('\\', '/'));
VirtualFile f = dir.child(n);
e.setTime(f.lastModified());
zos.putNextEntry(e);
try (InputStream in = f.open()) {
IOUtils.copy(in, zos);
}
zos.closeEntry();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!