Here you can find the source of openStreamUseCache(URL url)
url.openStream
except that the accessed resource may be a cached copy.
Parameter | Description |
---|---|
url | URL for which an input stream must be opened |
public static InputStream openStreamUseCache(URL url) throws IOException
//package com.java2s; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; public class Main { /**/* ww w . j a v a 2 s. c o m*/ * Similar to <code>url.openStream</code> except that the accessed * resource may be a cached copy. * * @param url URL for which an input stream must be opened * @return opened input stream * @exception IOException if the input stream cannot be opened * @see #openConnectionUseCache(URL) */ public static InputStream openStreamUseCache(URL url) throws IOException { URLConnection connection = openConnectionUseCache(url); return connection.getInputStream(); } /** * Similar to <code>url.openConnection</code> except that the accessed * resource may be a cached copy. * * @param url URL for which an URLConnection must be opened * @exception IOException if URLConnection cannot be opened * @see #openStreamUseCache(URL) */ public static URLConnection openConnectionUseCache(URL url) throws IOException { URLConnection connection = url.openConnection(); connection.setUseCaches(true); // Normally the default, so just in case. return connection; } }