Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. for (File f: myPath.toFile().listFiles()) {
  2. Class clazz = null;
  3. if (f.getName().endsWith(".class")) {
  4. try
  5. {
  6. clazz = (new MyClassLoader()).loadClass("com.javarush.test.level35.lesson10.bonus01.data." + f.getName().substring(0, f.getName().indexOf(".class")));
  7. }
  8. catch (ClassNotFoundException ignored)
  9. {
  10. }
  11. if (clazz != null) {
  12. try
  13. {
  14. Animal animal = (Animal) clazz.newInstance();
  15. allAnimals.add(animal);
  16. }
  17. catch (InstantiationException ignored)
  18. {
  19. }
  20. catch (IllegalAccessException ignored)
  21. {
  22. }
  23. catch (ClassCastException ignored) {
  24.  
  25. }
  26. }
  27.  
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement