Ejemplo n.º 1
0
 /**
  * 通过反射的方式遍历对象的属性和属性值,方便调试
  *
  * @param o 要遍历的对象
  * @throws Exception
  */
 public static void reflect(Object o) throws Exception {
   Class cls = o.getClass();
   Field[] fields = cls.getDeclaredFields();
   for (int i = 0; i < fields.length; i++) {
     Field f = fields[i];
     f.setAccessible(true);
     Util.log(f.getName() + " -> " + f.get(o));
   }
 }
Ejemplo n.º 2
0
 /**
  * 读取本地的xml数据,一般用来自测用
  *
  * @param localPath 本地xml文件路径
  * @return 读到的xml字符串
  */
 public static String getLocalXMLString(String localPath) throws IOException {
   return Util.inputStreamToString(Util.class.getResourceAsStream(localPath));
 }