Inheritance: global::java.lang.Object
示例#1
0
        /// <summary>
        /// Returns an input stream for reading the specified resource.
        /// If this loader is closed, then any resources opened by this method
        /// will be closed.
        ///
        /// <para> The search order is described in the documentation for {@link
        /// #getResource(String)}.  </para>
        /// </summary>
        /// <param name="name">
        ///         The resource name
        /// </param>
        /// <returns>  An input stream for reading the resource, or {@code null}
        ///          if the resource could not be found
        ///
        /// @since  1.7 </returns>
        public override InputStream GetResourceAsStream(String name)
        {
            URL url = GetResource(name);

            try
            {
                if (url == null)
                {
                    return(null);
                }
                URLConnection urlc = url.OpenConnection();
                InputStream   @is  = urlc.InputStream;
                if (urlc is JarURLConnection)
                {
                    JarURLConnection juc = (JarURLConnection)urlc;
                    JarFile          jar = juc.JarFile;
                    lock (Closeables)
                    {
                        if (!Closeables.ContainsKey(jar))
                        {
                            Closeables.Put(jar, null);
                        }
                    }
                }
                else if (urlc is sun.net.www.protocol.file.FileURLConnection)
                {
                    lock (Closeables)
                    {
                        Closeables.Put(@is, null);
                    }
                }
                return(@is);
            }
            catch (IOException)
            {
                return(null);
            }
        }
示例#2
0
        /// <summary>
        /// The protocol handler calls this method after a resource has
        /// been retrieved, and the ResponseCache must decide whether or
        /// not to store the resource in its cache. If the resource is to
        /// be cached, then put() must return a CacheRequest object which
        /// contains an OutputStream that the protocol handler will
        /// use to write the resource into the cache. If the resource is
        /// not to be cached, then put must return null.
        /// </summary>
        /// <param name="uri"> a {@code URI} used to reference the requested
        ///            network resource </param>
        /// <param name="conn"> - a URLConnection instance that is used to fetch
        ///            the response to be cached </param>
        /// <returns> a {@code CacheRequest} for recording the
        ///            response to be cached. Null return indicates that
        ///            the caller does not intend to cache the response. </returns>
        /// <exception cref="IOException"> if an I/O error occurs </exception>
        /// <exception cref="IllegalArgumentException"> if any one of the arguments is
        ///            null </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public abstract CacheRequest put(URI uri, URLConnection conn) throws java.io.IOException;
        public abstract CacheRequest Put(URI uri, URLConnection conn);