日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)鴻蒙OS教程:鴻蒙OSJarURLConnection

JarURLConnection

java.lang.Object

|---java.net.URLConnection

|---|---java.net.JarURLConnection

public abstract class JarURLConnection
extends URLConnection

與 Java ARchive (JAR) 文件或 JAR 文件中的條目的 URL 連接。

JAR URL 的語法是:

 jar:!/{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!/

當用戶知道他們創(chuàng)建的 URL 是 JAR URL 并且他們需要特定于 JAR 的功能時,他們應該將通用 URLConnection 轉(zhuǎn)換為 JarURLConnection。 例如:

 URL url = new URL("jar:file:/home/duke/duke.jar!/");
 JarURLConnection jarConnection = (JarURLConnection)url.openConnection();
 Manifest manifest = jarConnection.getManifest();

JarURLConnection 實例只能用于從 JAR 文件中讀取。 無法使用此類獲取 OutputStream 來修改或?qū)懭氲讓?JAR 文件。

例如:

一個 Jar 條目

jar:http://www.foo.com/bar/baz.jar!/COM/foo/Quux.class

一個 Jar 文件

jar:http://www.foo.com/bar/baz.jar!/

一個 Jar 目錄

jar:http://www.foo.com/bar/baz.jar!/COM/foo/

!/ 被稱為分隔符。

通過 new URL(context, spec) 構(gòu)造 JAR url 時,適用以下規(guī)則:

  • 如果沒有上下文 URL 并且傳遞給 URL 構(gòu)造函數(shù)的規(guī)范不包含分隔符,則認為 URL 引用了 JarFile。
  • 如果存在上下文 URL,則假定上下文 URL 引用 JAR 文件或 Jar 目錄。
  • 如果規(guī)范以“/”開頭,則忽略 Jar 目錄,并認為規(guī)范位于 Jar 文件的根目錄。

例如:

上下文:jar:http://www.foo.com/bar/jar.jar!/, spec:baz/entry.txt

url:jar:http://www.foo.com/bar/jar.jar!/baz/entry.txt

上下文:jar:http://www.foo.com/bar/jar.jar!/baz, spec:entry.txt

url:jar:http://www.foo.com/bar/jar.jar!/baz/entry.txt

上下文:jar:http://www.foo.com/bar/jar.jar!/baz, spec:/entry.txt

url:jar:http://www.foo.com/bar/jar.jar!/entry.txt

字段摘要

修飾符和類型 字段 描述
protected URLConnection jarFileURLConnection 與 JAR 文件 URL 的連接(如果已啟動連接)。
從類 java.net.URLConnection 繼承的字段
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches

構(gòu)造函數(shù)摘要

修飾符 構(gòu)造函數(shù) 描述
protected JarURLConnection(URL url) 為指定的 URL 創(chuàng)建新的 JarURLConnection。

方法總結(jié)

修飾符和類型 方法 描述
Attributes getAttributes() 如果該連接的 URL 指向 JAR 文件條目,則返回該連接的 Attributes 對象,否則返回 null。
Certificate[] getCertificates() 如果此連接的 URL 指向 JAR 文件條目,則返回此連接的證書對象,否則返回 null。
String getEntryName() 返回此連接的條目名稱。
JarEntry getJarEntry() 返回此連接的 JAR 條目對象(如果有)。
abstract JarFile getJarFile() 返回此連接的 JAR 文件。
URL getJarFileURL() 返回此連接的 Jar 文件的 URL。
Attributes getMainAttributes() 返回此連接的 JAR 文件的主要屬性。
Manifest getManifest() 返回此連接的清單,如果沒有則返回 null。
從類 java.lang.Object 繼承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
從類 java.net.URLConnection 繼承的方法
addRequestProperty, connect, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getContentEncoding, getContentLength, getContentLengthLong, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldKey, getHeaderFieldLong, getHeaderFields, getIfModifiedSince, getInputStream, getLastModified, getOutputStream, getPermission, getReadTimeout, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setConnectTimeout, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setReadTimeout, setRequestProperty, setUseCaches, toString

字段詳細信息

jarFileURLConnection

protected URLConnection jarFileURLConnection

與 JAR 文件 URL 的連接(如果已啟動連接)。 這應該由連接設置。

構(gòu)造函數(shù)詳細信息

JarURLConnection

protected JarURLConnection(URL url) throws MalformedURLException

為指定的 URL 創(chuàng)建新的 JarURLConnection。

參數(shù):

參數(shù)名稱 參數(shù)描述
url 網(wǎng)址

Throws:

Throw名稱 Throw描述
MalformedURLException 如果在規(guī)范字符串中找不到合法協(xié)議或無法解析字符串。

方法詳情

getJarFileURL

public URL getJarFileURL()

返回此連接的 Jar 文件的 URL。

返回:

此連接的 Jar 文件的 URL。

getEntryName

public String getEntryName()

返回此連接的條目名稱。 如果與此連接對應的 JAR 文件 URL 指向 JAR 文件而不是 JAR 文件條目,則此方法返回 null。

返回:

此連接的條目名稱(如果有)。

getJarFile

public abstract JarFile getJarFile() throws IOException

返回此連接的 JAR 文件。

返回:

此連接的 JAR 文件。 如果連接是到 JAR 文件條目的連接,則返回 JAR 文件對象

Throws:

Throw名稱 Throw描述
IOException 如果在嘗試連接到此連接的 JAR 文件時發(fā)生 IOException。

getManifest

public Manifest getManifest() throws IOException

返回此連接的清單,如果沒有則返回 null。

返回:

與此連接的 JAR 文件對象對應的清單對象。

Throws:

Throw名稱 Throw描述
IOException 如果獲取此連接的 JAR 文件會導致拋出 IOException。

getJarEntry

public JarEntry getJarEntry() throws IOException

返回此連接的 JAR 條目對象(如果有)。 如果與此連接對應的 JAR 文件 URL 指向 JAR 文件而不是 JAR 文件條目,則此方法返回 null。

返回:

此連接的 JAR 條目對象,如果此連接的 JAR URL 指向 JAR 文件,則返回 null。

Throws:

Throw名稱 Throw描述
IOException 如果獲取此連接的 JAR 文件會導致拋出 IOException。

getAttributes

public Attributes getAttributes() throws IOException

如果該連接的 URL 指向 JAR 文件條目,則返回該連接的 Attributes 對象,否則返回 null。

返回:

如果此連接的 URL 指向 JAR 文件條目,則為該連接的 Attributes 對象,否則為 null。

Throws:

Throw名稱 Throw描述
IOException 如果獲取 JAR 條目導致拋出 IOException。

getMainAttributes

public Attributes getMainAttributes() throws IOException

返回此連接的 JAR 文件的主要屬性。

返回:

此連接的 JAR 文件的主要屬性。

Throws:

Throw名稱 Throw描述
IOException 如果獲取清單導致拋出 IOException。

getCertificates

public Certificate[] getCertificates() throws IOException

如果此連接的 URL 指向 JAR 文件條目,則返回此連接的證書對象,否則返回 null。 只有在通過從輸入流中讀取直到到達流的末尾來完全驗證連接后,才能調(diào)用此方法。 否則,此方法將返回 null

返回:

如果此連接的 URL 指向 JAR 文件條目,則為該連接的 Certificate 對象,否則為 null。

Throws:

Throw名稱 Throw描述
IOException 如果獲取 JAR 條目導致拋出 IOException。

分享標題:創(chuàng)新互聯(lián)鴻蒙OS教程:鴻蒙OSJarURLConnection
URL標題:http://www.5511xx.com/article/cdhihjj.html