怎么出现这样的结果?
public class ReflectTest {
public static void main(String[] args) {
Class c = null;
try {
c = Class.forName(args[0]);
System.out.println("package " + c.getPackage().getName());// 获取包名
System.out.print(Modifier.toString(c.getModifiers()));// 获取类的修饰符
System.out.print(" class " + c.getSimpleName());// 获取类名
System.out.print(" extends " + c.getSuperclass().getSimpleName());// 获取父类名
Class[] inters = c.getInterfaces();
if (inters.length > 0) {
System.out.print(" implements ");
for (int i = 0; i < inters.length; i++) {//
System.out.print(inters[i].getSimpleName());
if (i < inters.length - 1) {
System.out.print(",");
}
}
}
System.out.println("{");
System.out.println("\n\t// all fields:");
PrintFields(c);
System.out.println("\n\t// all Constructors:");
printConstructors(c);
System.out.println("\n\t// all Methods:");
printMethods(c);
System.out.println("}");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public static void PrintFields(Class c) {// 获取属性
Field[] fields = c.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
Field f = fields[i];
System.out.print("\t" + Modifier.toString(f.getModifiers()));// getModifiers()得到属性修饰符
System.out.print(" " + f.getType().getSimpleName());// getType()得到属性数据类型
System.out.println(" " + f.getName() + ";");// getName()得到属性名
}
}
public static void printConstructors(Class c) {// 获取构造方法
Constructor[] cons = c.getDeclaredConstructors();
for (int i = 0; i < cons.length; i++) {
Constructor con = cons[i];
System.out.print("\t" + Modifier.toString(con.getModifiers()));// 构造方法的修饰符
System.out.print(" " + c.getSimpleName() + "(");// 构造方法的方法名
Class[] allPara = con.getParameterTypes();
for (int j = 0; j < allPara.length; j++) {
System.out.print(allPara[j].getSimpleName() + " args" + j);// 参数(形参)类型
if (j < allPara.length - 1) {
System.out.print(",");
}
}
System.out.println(")");
Class[] allException = con.getExceptionTypes();//异常
if (allException.length > 0) {
System.out.print(" throws ");
for (int k = 0; k < allException.length; k++) {
System.out.print(allException[k].getSimpleName());
if (k < allException.length - 1) {
System.out.print(",");
}
}
}
}
System.out.println("{ ...... }");
}
public static void printMethods(Class c) {// 获取方法
Method[] allMethods = c.getDeclaredMethods();
for (int i = 0; i < allMethods.length; i++) {
Method m = allMethods[i];
System.out.print("\t" + Modifier.toString(m.getModifiers()));// 修饰符
System.out.print(" " + m.getReturnType());// 返回值类型
System.out.print(" " + m.getName() + "(");// 方法名
Class[] allPara = m.getParameterTypes();
for (int j = 0; j < allPara.length; j++) {
System.out.print(allPara[j].getSimpleName() + " args" + j);// 参数(形参)类型
if (j < allPara.length - 1) {
System.out.print(",");
}
}
System.out.print(")");
Class[] allException = m.getExceptionTypes();//异常
if (allException.length > 0) {
System.out.print(" throws ");
for (int k = 0; k < allException.length; k++) {
System.out.print(allException[k].getSimpleName());
if (k < allException.length - 1) {
System.out.print(",");
}
}
}
System.out.print("{");
System.out.print("......");
System.out.print("}");
}
}
}
这个程序哪里出错了,运行结果怎么出现UnsupportedEncodingException,什么意思啊