Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. static void checkMethods(File someFile){
  2. //Here I want to print the methods in this file
  3. //here's what I have so far
  4. String fname = someFile.getClass().getCanonicalName();
  5.  
  6. int Mcount = 0;
  7. try {
  8. Class cls = Class.forName(fname);
  9. Method methlist[] = cls.getDeclaredMethods();
  10. for (int i = 0; i < methlist.length; i++) {
  11. Method m = methlist[i];
  12. Mcount = Mcount + 1;
  13. }
  14. for (Class clazz = cls ; clazz != null; clazz = clazz.getSuperclass()) {
  15. System.out.println("Methods for Class" + clazz.getName());
  16. for (Method m : clazz.getDeclaredMethods()) {
  17. System.out.println(m);
  18. }
  19. }
  20. } catch (Throwable e) {
  21. System.err.println(e);
  22. }
  23. System.out.println("Mcount = " + Mcount);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement