本文整理了Java中org.openide.filesystems.FileUtil.extractJar()
方法的一些代码示例,展示了FileUtil.extractJar()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.extractJar()
方法的具体详情如下:
包路径:org.openide.filesystems.FileUtil
类名称:FileUtil
方法名:extractJar
[英]Extract jar file into folder represented by file object. If the JAR contains files with name filesystem.attributes, it is assumed that these files has been created by DefaultAttributes implementation and the content of these files is treated as attributes and added to extracted files.
META-INF/
directories are skipped over.
[中]将jar文件解压缩到文件对象表示的文件夹中。如果JAR包含名为filesystem的文件。属性,假定这些文件是由DefaultAttributes实现创建的,并且这些文件的内容被视为属性并添加到提取的文件中。
将跳过META-INF/
目录。
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-insync
/**
* Given a jar file and a dir name extract the jar file into the dirname in
* the cache directory
*/
private String extract(String jar, String dirname) {
String cacheDir = System.getProperty("netbeans.user") + "/var/cache/" + dirname;
try {
File f = new File(cacheDir);
if (f.exists()) {
// Cache already exists. Assume current. Perhaps we should look
// at the time and occasionally regenerate - or is there a way to
// look at the checksum of the jar perhaps?
return cacheDir;
}
String message = NbBundle.getMessage(BrowserPreview.class, "ExtractingJars");
StatusDisplayer.getDefault().setStatusText(message);
f.mkdirs();
FileObject fo = FileUtil.toFileObject(f);
InputStream is = new BufferedInputStream(new FileInputStream(new File(jar)));
FileUtil.extractJar(fo, is);
return cacheDir;
} catch (Exception e) {
ErrorManager.getDefault().notify(e);
return null;
} finally {
StatusDisplayer.getDefault().setStatusText("");
}
}
代码示例来源:origin: org.codehaus.mevenide/grammar
@Override
public void restored() {
super.restored();
File expandedPath = InstalledFileLocator.getDefault().locate("maven2/maven-plugins-xml", null, false); //NOI18N
File upgrade = expandedPath == null ? null : new File(expandedPath, UPGRADE_PATH);
if (expandedPath == null || !expandedPath.exists() || (expandedPath != null && expandedPath.exists() && !upgrade.exists())) {
File zipFile = InstalledFileLocator.getDefault().locate("maven2/maven-plugins-xml.zip", null, false); //NOI18N
assert zipFile != null : "Wrong installation, maven2/maven-plugins-xml.zip missing"; //NOI18N
//TODO place somewhere else to make sure it's writable by user?
expandedPath = new File(zipFile.getParentFile(), "maven-plugins-xml"); //NOI18N
FileObject fo=null;
InputStream in = null;
try {
fo = FileUtil.createFolder(expandedPath);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
try {
in = new FileInputStream(zipFile);
FileUtil.extractJar(fo, in);
} catch (IOException exc) {
} finally {
IOUtil.close(in);
}
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-apisupport-feedreader
InputStream is = template.getInputStream();
try {
FileUtil.extractJar(dir, is);
} finally {
is.close();
内容来源于网络,如有侵权,请联系作者删除!