httpperftaskparam.java

来自「利用Java Socket写的一段通讯协议」· Java 代码 · 共 46 行

JAVA
46
字号
package com.ict.netcom2.task;

import java.io.*;

public class HttpPerfTaskParam extends TaskParam {
	
	private long testTimes;

	private int port;

	private int interval;

	private int prototype;

	private String url;

	public HttpPerfTaskParam(long testTimes, int port, int interval,
			int prototype, String url) {
		this.testTimes = testTimes;
		this.port = port;
		this.interval = interval;
		this.prototype = prototype;
		this.url = url;
		encode();
	}

	private void encode() {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		DataOutputStream dos = new DataOutputStream(baos);
		try {
			dos.writeInt((int) (testTimes));
			dos.writeShort(url.length());
			dos.writeShort(port);
			dos.writeShort(interval);
			dos.writeShort(prototype);
			dos.writeBytes(url);
			dos.close();
			baos.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		paramCode = baos.toByteArray();
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?