本文整理汇总了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();
}