Пример #1
0
        // Parse the content of the given URL as a provider-configuration file.
        //
        // @param  service
        //         The service type for which providers are being sought;
        //         used to construct error detail strings
        //
        // @param  u
        //         The URL naming the configuration file to be parsed
        //
        // @return A (possibly empty) iterator that will yield the provider-class
        //         names in the given configuration file that are not yet members
        //         of the returned set
        //
        // @throws ServiceConfigurationError
        //         If an I/O error occurs while reading from the given URL, or
        //         if a configuration-file format error is detected
        //
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private java.util.Iterator<String> parse(Class service, java.net.URL u) throws ServiceConfigurationError
        private IEnumerator <String> Parse(Class service, URL u)
        {
            InputStream    @in   = null;
            BufferedReader r     = null;
            List <String>  names = new List <String>();

            try
            {
                @in = u.OpenStream();
                r   = new BufferedReader(new InputStreamReader(@in, "utf-8"));
                int lc = 1;
                while ((lc = ParseLine(service, u, r, lc, names)) >= 0)
                {
                    ;
                }
            }
            catch (IOException x)
            {
                Fail(service, "Error reading configuration file", x);
            }
            finally
            {
                try
                {
                    if (r != null)
                    {
                        r.Close();
                    }
                    if (@in != null)
                    {
                        @in.Close();
                    }
                }
                catch (IOException y)
                {
                    Fail(service, "Error closing configuration file", y);
                }
            }
            return(names.Iterator());
        }