本文整理匯總了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();
}
示例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();
}
示例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;
}
示例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();
}
示例5: FileUrlJar
import java.net.JarURLConnection; //導入方法依賴的package包/類
public FileUrlJar(URL url) throws IOException {
JarURLConnection jarConn = (JarURLConnection) url.openConnection();
jarConn.setUseCaches(false);
jarFile = jarConn.getJarFile();
}
示例6: FileUrlJar
import java.net.JarURLConnection; //導入方法依賴的package包/類
public FileUrlJar(URL url) throws IOException {
JarURLConnection jarConn = (JarURLConnection) url.openConnection();
jarConn.setUseCaches(false);
jarFile = jarConn.getJarFile();
}