|
JavaTM 2 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 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。