[代码] 用java反射机制和正则表达式完成PHP式query句子 package jaakan.util;

public class ReadClassAttribute {

	/**
	 * @param args
	 */

	public static String readAttribute(Object obj,String attributeName){
		 ; String value=null;
		try {
			java.lang.reflect.Field field=obj.getClass().getDeclaredField(attributeName);
			field.setAccessible(true);
			value=(String)field.get(obj);
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchFieldException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return value;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

} ; 
10-06 00:12