|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjava.net.URLConnection
java.net.JarURLConnection
public abstract class JarURLConnection
连接到 Java ARchive (JAR) 文件或 JAR 文件中条目的 URL Connection。
JAR URL 的语法为:
jar:<url>!/{entry}
例如:
jar:http://www.foo.com/bar/baz.jar!/COM/foo/Quux.class
应该使用 Jar URL 来引用 JAR 文件或 JAR 文件中的条目。上述示例是一个引用 JAR 条目的 JAR URL。如果省略条目名,则 URL 引用整个 JAR 文件:
jar:http://www.foo.com/bar/baz.jar!/
当用户知道他们创建的 URL 为 JAR URL 并且需要特定于 JAR 的功能时,应该将一般 URLConnection 强制转换为 JarURLConnection。例如:
URL url = new URL("jar:file:/home/duke/duke.jar!/");
JarURLConnection jarConnection = (JarURLConnection)url.openConnection();
Manifest manifest = jarConnection.getManifest();
JarURLConnection 实例只能用于从 JAR 文件读取内容。使用此类获取 OutputStream 从而修改或写入基础 JAR 文件是不可能的。
示例:
jar:http://www.foo.com/bar/baz.jar!/COM/foo/Quux.class
jar:http://www.foo.com/bar/baz.jar!/
jar:http://www.foo.com/bar/baz.jar!/COM/foo/
!/ 被视为分隔符。
通过 new URL(context, spec) 构造 JAR url 时,将应用以下规则:
示例:
URL,
URLConnection,
JarFile,
JarInputStream,
Manifest,
ZipEntry| 字段摘要 | |
|---|---|
protected URLConnection |
jarFileURLConnection
到 JAR 文件 URL 的连接,如果已启动连接。 |
| 从类 java.net.URLConnection 继承的字段 |
|---|
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches |
| 构造方法摘要 | |
|---|---|
protected |
JarURLConnection(URL url)
创建到指定 URL 的新 JarURLConnection。 |
| 方法摘要 | |
|---|---|
Attributes |
getAttributes()
如果此连接的 URL 指向 JAR 文件条目,则返回其 Attribute 对象;否则返回 null。 |
Certificate[] |
getCertificates()
如果此连接的 URL 指向 JAR 文件条目,则返回其 Certificate 对象;否则返回 null。 |
String |
getEntryName()
返回此连接的条目名称。 |
JarEntry |
getJarEntry()
返回此连接的 JAR 条目对象(如果有)。 |
abstract JarFile |
getJarFile()
返回此连接的 JAR 文件。 |
URL |
getJarFileURL()
返回此连接的 Jar 文件的 URL。 |
Attributes |
getMainAttributes()
返回此连接的 JAR 文件的主要 Attribute。 |
Manifest |
getManifest()
返回此连接的 Manifest;如果没有,则返回 null。 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 字段详细信息 |
|---|
protected URLConnection jarFileURLConnection
| 构造方法详细信息 |
|---|
protected JarURLConnection(URL url)
throws MalformedURLException
url - URL
MalformedURLException - 如果在规范字符串中找不到合法协议或者无法解析该字符串。| 方法详细信息 |
|---|
public URL getJarFileURL()
public String getEntryName()
public abstract JarFile getJarFile()
throws IOException
IOException - 如果在试图连接到此连接的 JAR 文件时发生 IOException。URLConnection.connect()
public Manifest getManifest()
throws IOException
IOException - 如果获取此连接的 JAR 文件导致抛出 IOException。getJarFile()
public JarEntry getJarEntry()
throws IOException
IOException - 如果获取此连接的 JAR 文件导致抛出 IOException。getJarFile(),
getJarEntry()
public Attributes getAttributes()
throws IOException
IOException - 如果获取 JAR 条目导致抛出 IOException。getJarEntry()
public Attributes getMainAttributes()
throws IOException
IOException - 如果获取清单导致抛出 IOException。getJarFile(),
getManifest()
public Certificate[] getCertificates()
throws IOException
null。
IOException - 如果获取 JAR 条目导致抛出 IOException。getJarEntry()
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。