當前位置: 首頁>>代碼示例>>Java>>正文


Java JarURLConnection.setUseCaches方法代碼示例

本文整理匯總了Java中java.net.JarURLConnection.setUseCaches方法的典型用法代碼示例。如果您正苦於以下問題:Java JarURLConnection.setUseCaches方法的具體用法?Java JarURLConnection.setUseCaches怎麽用?Java JarURLConnection.setUseCaches使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.net.JarURLConnection的用法示例。


在下文中一共展示了JarURLConnection.setUseCaches方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import java.net.JarURLConnection; //導入方法依賴的package包/類
public static void main( String[] args ) throws IOException {
    JarOutputStream out = new JarOutputStream(
            new FileOutputStream("usecache.jar"));
    out.putNextEntry(new JarEntry("test.txt"));
    out.write("Test txt file".getBytes());
    out.closeEntry();
    out.close();

    URL url = new URL("jar:"
        + new File(".").toURI().toString()
        + "/usecache.jar!/test.txt");

    JarURLConnection c1 = (JarURLConnection)url.openConnection();
    c1.setDefaultUseCaches( false );
    c1.setUseCaches( true );
    c1.connect();

    JarURLConnection c2 = (JarURLConnection)url.openConnection();
    c2.setDefaultUseCaches( false );
    c2.setUseCaches( true );
    c2.connect();

    c1.getInputStream().close();
    c2.getInputStream().read();
    c2.getInputStream().close();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:27,代碼來源:JarURLConnectionUseCaches.java

示例2: getJarFile

import java.net.JarURLConnection; //導入方法依賴的package包/類
@Override
public JarFile getJarFile() throws IOException {
    URL jarFileUrl = new URL("jar:" + jarUrl + "!/");
    JarURLConnection conn = (JarURLConnection) jarFileUrl.openConnection();
    conn.setUseCaches(false);
    conn.connect();
    return conn.getJarFile();
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:9,代碼來源:JarURLResource.java

示例3: getJarFile

import java.net.JarURLConnection; //導入方法依賴的package包/類
private JarFile getJarFile(URL jarFileUrl) throws IOException {
    JarFile jarFile = null;

    if (jarFileUrl != null) {
        JarURLConnection conn = (JarURLConnection) jarFileUrl.openConnection();
        conn.setUseCaches(false);
        conn.connect();
        jarFile = conn.getJarFile();
    }

    return jarFile;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:13,代碼來源:ParserController.java

示例4: getJarFile

import java.net.JarURLConnection; //導入方法依賴的package包/類
@Override
public JarFile getJarFile() throws IOException {
	URL jarFileUrl = new URL("jar:" + jarUrl + "!/");
	JarURLConnection conn = (JarURLConnection) jarFileUrl.openConnection();
	conn.setUseCaches(false);
	conn.connect();
	return conn.getJarFile();
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:9,代碼來源:JarURLResource.java

示例5: FileUrlJar

import java.net.JarURLConnection; //導入方法依賴的package包/類
public FileUrlJar(URL url) throws IOException {
    JarURLConnection jarConn = (JarURLConnection) url.openConnection();
    jarConn.setUseCaches(false);
    jarFile = jarConn.getJarFile();
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:6,代碼來源:FileUrlJar.java

示例6: FileUrlJar

import java.net.JarURLConnection; //導入方法依賴的package包/類
public FileUrlJar(URL url) throws IOException {
	JarURLConnection jarConn = (JarURLConnection) url.openConnection();
	jarConn.setUseCaches(false);
	jarFile = jarConn.getJarFile();
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:6,代碼來源:FileUrlJar.java


注:本文中的java.net.JarURLConnection.setUseCaches方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。