Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (File f: myPath.toFile().listFiles()) {
- Class clazz = null;
- if (f.getName().endsWith(".class")) {
- try
- {
- clazz = (new MyClassLoader()).loadClass("com.javarush.test.level35.lesson10.bonus01.data." + f.getName().substring(0, f.getName().indexOf(".class")));
- }
- catch (ClassNotFoundException ignored)
- {
- }
- if (clazz != null) {
- try
- {
- Animal animal = (Animal) clazz.newInstance();
- allAnimals.add(animal);
- }
- catch (InstantiationException ignored)
- {
- }
- catch (IllegalAccessException ignored)
- {
- }
- catch (ClassCastException ignored) {
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement