JAVA 控制台循环输入

public void sendPWlistResultRet(String[] args) throws Exception {
		System.out.println("开始测试:");
		BufferedReader reader = null;

		PWlistResultRetPtc p = new PWlistResultRetPtc();

		boolean flag = true;
		while (flag) {
			Thread.sleep(3000);
			boolean flag2 = true;
			int flag3 = 0;
			while (flag2) {
				System.out.print("\t请输入'事件编号'(最长16,不能为空):");
				reader = new BufferedReader(new InputStreamReader(System.in));
				String eventId = reader.readLine().trim();
				if (isContinue(eventId)) {
					flag3 = 1;
					flag2 = false;
				} else if (isExit(eventId)) {
					flag3 = 2;
					flag2 = false;
				} else {
					if (eventId.length() > 0 && eventId.length() <= 16) {
						p.setEventId(eventId);
						flag2 = false;
					}
				}
			}
			if (flag3 == 1) {
				continue;
			} else if (flag3 == 2) {
				break;
			}
			flag3 = 0;
			flag2 = true;
			while (flag2) {
				System.out.print("\t请输入'文件名称'(最长64,不能为空):");
				reader = new BufferedReader(new InputStreamReader(System.in));
				String fileName = reader.readLine().trim();
				if (isContinue(fileName)) {
					flag3 = 1;
					flag2 = false;
				} else if (isExit(fileName)) {
					flag3 = 2;
					flag2 = false;
				} else {
					if (fileName.length() > 0 && fileName.length() <= 64) {
						p.setFileName(fileName);
						flag2 = false;
					}
				}
			}
			if (flag3 == 1) {
				continue;
			} else if (flag3 == 2) {
				break;
			}
			flag3 = 0;
			flag2 = true;
			while (flag2) {
				System.out.print("\t请输入'文件大小'(最大4倍整数,不能为空):");
				reader = new BufferedReader(new InputStreamReader(System.in));
				String fileSize = reader.readLine().trim();
				if (isContinue(fileSize)) {
					flag3 = 1;
					flag2 = false;
				} else if (isExit(fileSize)) {
					flag3 = 2;
					flag2 = false;
				} else {
					try {
						int size = Integer.parseInt(fileSize);
						if (size > 0 && size <= 9999) {
							p.setFileSize((short) size);
							flag2 = false;
						}
					} catch (Exception e) {

					}
				}
			}
			System.out.println("调用接口开始:");
			sendBytes(p.toBytes());
			System.out.println("调用接口结束!");
			flag = false;
		}
		System.out.println("结束测试");
	}

	public static void main(String[] args) throws Exception {
		System.out.println("测试开始:");
		BufferedReader reader = null;
		boolean flag = true;
		System.out.println("接口:\n  1:接口1\n  2:接口2\n  3: 接口3");
		while (flag) {
			System.out.print("请输入要测试的接口:");
			try {
				reader = new BufferedReader(new InputStreamReader(System.in));
				String command = reader.readLine().trim();

				TestWspMinaClient wmc = new TestWspMinaClient();
				wmc.connect();

				if (command.equalsIgnoreCase("1")) {
					wmc.sendLimitListSyncReq(args);
				} else if (command.equalsIgnoreCase("2")) {
					wmc.sendMWlistSyncReq(args);
				} else if (command.equalsIgnoreCase("3")) {
					wmc.sendPWlistResultRet(args);
				} else {
					System.out.println("输入参数错误!");
					continue;
				}
			} catch (Exception e) {
				e.printStackTrace();
				continue;
			}
			boolean flag2 = true;
			while (flag2) {
				try {
					System.out.print("是否继续测试,Y/N:");
					reader = new BufferedReader(new InputStreamReader(System.in));
					String yOrN = reader.readLine().trim();
					if (yOrN.equalsIgnoreCase("Y")) {
						flag2 = false;
					} else if (yOrN.equalsIgnoreCase("N")) {
						flag = false;
						flag2 = false;
					}
				} catch (Exception e) {
					e.printStackTrace();
					continue;
				}
			}
		}
		System.out.println("测试结束!");
	}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值