Java URL Load loadImplementations(URL url, ClassLoader loader)

Here you can find the source of loadImplementations(URL url, ClassLoader loader)

Description

load Implementations

License

Apache License

Declaration

public static List<Class> loadImplementations(URL url, ClassLoader loader)
            throws IOException, ClassNotFoundException 

Method Source Code


//package com.java2s;
/*//from ww w.j  a  v a 2 s  .co m
 *
 * Copyright (c) 2016. Vijayakumar Mohan
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * JMattr - The meta attribute library for java!
 *
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import java.net.URL;

import java.util.*;

public class Main {
    public static List<Class> loadImplementations(URL url, ClassLoader loader)
            throws IOException, ClassNotFoundException {
        InputStream inputStream = url.openStream();
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        String classLine = reader.readLine();
        ArrayList<Class> classList = new ArrayList<>();
        while (classLine != null) {

            //ask the classloader to load the class
            Class clz = loader.loadClass(classLine);

            //add the class to the list
            classList.add(clz);

            classLine = reader.readLine();
        }
        reader.close();
        return classList;
    }
}

Related

  1. loadFromURL(URL url)
  2. loadFromURL(URL url)
  3. loadFromURL(URL url)
  4. loadFully(URL url)
  5. loadFully(URL url)
  6. loadManifest(URL url)
  7. loadObject(URL url)
  8. loadProperties(final URL url)
  9. loadProperties(Properties p, URL url)