根据实例化bean用get,set获得所有属性值

图一代码如下:


图二代码如下:



根据图1得到图2代码

package com.abc.esb.connect;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

import org.apache.commons.lang.StringUtils;

/**
 * @title: 自动生成get set <br/>
 * @author: wangzs <br/>
 * @date: 2017年9月10日
 */
public class AutoGetSetUtils {

	public static void main(String[] args) {
		String fileName = "E:/PsdTktExchange.java";// 文件名字
		String beanName = "psdTktExchange";// java实例化bean名字

		File file = new File(fileName);
		BufferedReader reader = null;
		try {
			reader = new BufferedReader(new FileReader(file));
			String tempString = null;
			while ((tempString = reader.readLine()) != null) {
				tempString = StringUtils.trim(tempString);
				String[] words = tempString.split("\\s+");// [private, String, arrSchedule;]
				// 过滤出来以private开始&&以;结束
				if (tempString.startsWith("private") && tempString.endsWith(";")) {
					StringBuffer newLine = new StringBuffer();// String arrSchedule = psdTktCoupon.getArrSchedule();
					String attributesName = words[2].replace(";", "");
					newLine.append(words[1] + " ");
					newLine.append(attributesName);
					newLine.append(" = ");
					newLine.append(beanName + ".get");
					newLine.append(attributesName.substring(0, 1).toUpperCase() + attributesName.substring(1));
					newLine.append("();");
					System.out.println(newLine);
				}
			}
			reader.close();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (reader != null) {
				try {
					reader.close();
				} catch (IOException e1) {
				}
			}
		}

	}

}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值