本文整理汇总了Java中java.util.jar.JarEntry.getTime方法的典型用法代码示例。如果您正苦于以下问题:Java JarEntry.getTime方法的具体用法?Java JarEntry.getTime怎么用?Java JarEntry.getTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.jar.JarEntry
的用法示例。
在下文中一共展示了JarEntry.getTime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyStream
import java.util.jar.JarEntry; //导入方法依赖的package包/类
private void copyStream(InputStream inputStream, JarOutputStream jos, JarEntry ze, String pathName) {
try {
ZipEntry newEntry = new ZipEntry(pathName);
// Make sure there is date and time set.
if (ze.getTime() != -1) {
newEntry.setTime(ze.getTime());
newEntry.setCrc(ze.getCrc()); // If found set it into output file.
}
jos.putNextEntry(newEntry);
IOUtils.copy(inputStream, jos);
IOUtils.closeQuietly(inputStream);
} catch (Exception e) {
//throw new GradleException("copy stream exception", e);
//e.printStackTrace();
logger.error("copy stream exception >>> " + pathName + " >>>" + e.getMessage());
}
}
示例2: run
import java.util.jar.JarEntry; //导入方法依赖的package包/类
void run() throws Exception {
RelativeFile TEST_ENTRY_NAME = new RelativeFile("java/lang/String.class");
File testJar = createJar("test.jar", "java.lang.*");
try (JarFile j = new JarFile(testJar)) {
JarEntry je = j.getJarEntry(TEST_ENTRY_NAME.getPath());
long jarEntryTime = je.getTime();
Context context = new Context();
JavacFileManager fm = new JavacFileManager(context, false, null);
fm.setLocation(StandardLocation.CLASS_PATH, Collections.singletonList(testJar));
FileObject fo =
fm.getFileForInput(StandardLocation.CLASS_PATH, "", TEST_ENTRY_NAME.getPath());
long jfoTime = fo.getLastModified();
check(je, jarEntryTime, fo, jfoTime);
if (errors > 0)
throw new Exception(errors + " occurred");
}
}
示例3: urlLastModified
import java.util.jar.JarEntry; //导入方法依赖的package包/类
public static long urlLastModified(URL url) throws URISyntaxException, IOException {
url = osgiToJar(url);
if ("jar".equalsIgnoreCase(url.getProtocol())) {
JarURLConnection jarEntryConn = (JarURLConnection)url.openConnection();
// Check that the jar file actually exists on the file system
File file = new File(jarEntryConn.getJarFileURL().getPath());
if (!file.exists()) throw new IOException("Unable to process JAR url. JAR file is missing: " + file);
try (JarFile jarFile = new JarFile(file)) {
// Automatically reject any JAR URL which does not contain a JAR entry
String jarEntryName = jarEntryConn.getEntryName();
if (jarEntryName == null) throw new IOException("Unsupported JAR url. Missing JAR entry: " + url);
JarEntry jarEntry = jarFile.getJarEntry(jarEntryName);
return jarEntry != null ? jarEntry.getTime() : -1;
}
}
return new File(url.toURI()).lastModified();
}