@Test public void testgetClassNameByFile() { String file = System.getProperty("user.dir") + "/target/classes"; List<String> classNames = ClassUtil.getClassNameByFile(file, true); System.out.println(classNames); }
public final static List<String> getClassNameByFile(String filePath, boolean childPackage) { List<String> myClassName = new ArrayList<>(); List<File> files = FileUtil.listFile(filePath, childPackage); for (File file : files) { if (file.getName().endsWith(".class")) { String childFilePath = file.getPath(); int index = filePath.replaceAll("\\\\", ".").length(); childFilePath = childFilePath.replaceAll("\\\\", ".").substring(index+1, childFilePath.length()); myClassName.add(childFilePath); } } return myClassName; }
ClassUtil { public final static List<String> getClassNameByFile(String filePath, boolean childPackage) { List<String> myClassName = new ArrayList<>(); List<File> files = FileUtil.listFile(filePath, childPackage); for (File file : files) { if (file.getName().endsWith(".class")) { String childFilePath = file.getPath(); int index = filePath.replaceAll("\\\\", ".").length(); childFilePath = childFilePath.replaceAll("\\\\", ".").substring(index+1, childFilePath.length()); myClassName.add(childFilePath); } } return myClassName; } }
ClassUtil { public final static List<String> getClassNameByFile(String filePath, boolean childPackage) { List<String> myClassName = new ArrayList<>(); List<File> files = FileUtil.listFile(filePath, childPackage); for (File file : files) { if (file.getName().endsWith(".class")) { String childFilePath = file.getPath(); int index = filePath.replaceAll("\\\\", ".").length(); childFilePath = childFilePath.replaceAll("\\\\", ".").substring(index+1, childFilePath.length()); myClassName.add(childFilePath); } } return myClassName; }  }
ClassUtil { public final static List<String> getClassNameByFile(String filePath, boolean childPackage) { List<String> myClassName = new ArrayList<>(); List<File> files = FileUtil.listFile(filePath, childPackage); for (File file : files) { if (file.getName().endsWith(".class")) { String childFilePath = file.getPath(); int index = filePath.replaceAll("\\\\", ".").length(); childFilePath = childFilePath.replaceAll("\\\\", ".").substring(index+1, childFilePath.length()); myClassName.add(childFilePath); } } return myClassName; }  static ClassLoader getContextClassLoader(); final static String[] getField(String className, boolean extendsField); final static String[] getPublicField(String className, boolean extendsField); final static String[] getProtectedField(String className); final static String[] getPrivateField(String className); final static String[] getPublicMethod(String className, boolean extendsMethod); final static String[] getProtectedMethod(String className, boolean extendsMethod); final static String[] getPrivateMethod(String className); final static String[] getMethod(String className, boolean extendsMethod); final static void setter(Object obj, String att, Object value, Class<?> type); final static List<String> getClassNameByFile(String filePath, boolean childPackage); final static List<String> getClassNameByJar(String jarPath); final static Class loadClass(String className); final static List<String> getResourceNameByJar(String jarPath); final static List<String> getResourceNameByJar(String jarPath, String suffix); static List<Class> getLoaderClass(ClassLoader classLoader); final static String getSuperClass(String className); final static String[] getSuperClassChian(String className); final static String[] getInterfaces(String className, boolean extendsInterfaces); static File getFile(String resourceLocation); static File getFile(URL resourceUrl); static File getFile(URL resourceUrl, String description); static URI toURI(URL url); static URI toURI(String location); }
ClassUtil { public final static List<String> getClassNameByFile(String filePath, boolean childPackage) { List<String> myClassName = new ArrayList<>(); List<File> files = FileUtil.listFile(filePath, childPackage); for (File file : files) { if (file.getName().endsWith(".class")) { String childFilePath = file.getPath(); int index = filePath.replaceAll("\\\\", ".").length(); childFilePath = childFilePath.replaceAll("\\\\", ".").substring(index+1, childFilePath.length()); myClassName.add(childFilePath); } } return myClassName; }  static ClassLoader getContextClassLoader(); final static String[] getField(String className, boolean extendsField); final static String[] getPublicField(String className, boolean extendsField); final static String[] getProtectedField(String className); final static String[] getPrivateField(String className); final static String[] getPublicMethod(String className, boolean extendsMethod); final static String[] getProtectedMethod(String className, boolean extendsMethod); final static String[] getPrivateMethod(String className); final static String[] getMethod(String className, boolean extendsMethod); final static void setter(Object obj, String att, Object value, Class<?> type); final static List<String> getClassNameByFile(String filePath, boolean childPackage); final static List<String> getClassNameByJar(String jarPath); final static Class loadClass(String className); final static List<String> getResourceNameByJar(String jarPath); final static List<String> getResourceNameByJar(String jarPath, String suffix); static List<Class> getLoaderClass(ClassLoader classLoader); final static String getSuperClass(String className); final static String[] getSuperClassChian(String className); final static String[] getInterfaces(String className, boolean extendsInterfaces); static File getFile(String resourceLocation); static File getFile(URL resourceUrl); static File getFile(URL resourceUrl, String description); static URI toURI(URL url); static URI toURI(String location); static ClassLoader overridenClassLoader; }